diff --git a/tests/unit-tests/util/notification-stream.cpp b/tests/unit-tests/util/notification-stream.cpp
index adba5c7..4b6d43d 100644
--- a/tests/unit-tests/util/notification-stream.cpp
+++ b/tests/unit-tests/util/notification-stream.cpp
@@ -47,26 +47,29 @@
 
 #include "util/notification-stream.hpp"
 #include "simple-notification.hpp"
+#include "util/dummy-client-face.hpp"
 
 #include "boost-test.hpp"
-#include "util/dummy-client-face.hpp"
+#include "../unit-test-time-fixture.hpp"
 
 namespace ndn {
 namespace util {
 namespace tests {
 
-BOOST_AUTO_TEST_SUITE(UtilNotificationStream)
+BOOST_FIXTURE_TEST_SUITE(UtilNotificationStream, ndn::tests::UnitTestTimeFixture)
 
 BOOST_AUTO_TEST_CASE(Post)
 {
-  shared_ptr<DummyClientFace> face = makeDummyClientFace();
+  shared_ptr<DummyClientFace> face = makeDummyClientFace(io);
   ndn::KeyChain keyChain;
   util::NotificationStream<SimpleNotification> notificationStream(*face,
     "/localhost/nfd/NotificationStreamTest", keyChain);
 
   SimpleNotification event1("msg1");
   notificationStream.postNotification(event1);
-  face->processEvents();
+
+  advanceClocks(time::milliseconds(1));
+
   BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
   BOOST_CHECK_EQUAL(face->sentDatas[0].getName(),
                     "/localhost/nfd/NotificationStreamTest/%FE%00");
@@ -76,7 +79,9 @@
 
   SimpleNotification event2("msg2");
   notificationStream.postNotification(event2);
-  face->processEvents();
+
+  advanceClocks(time::milliseconds(1));
+
   BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 2);
   BOOST_CHECK_EQUAL(face->sentDatas[1].getName(),
                     "/localhost/nfd/NotificationStreamTest/%FE%01");
diff --git a/tests/unit-tests/util/notification-subscriber.cpp b/tests/unit-tests/util/notification-subscriber.cpp
index 9d7ab65..96f5bf4 100644
--- a/tests/unit-tests/util/notification-subscriber.cpp
+++ b/tests/unit-tests/util/notification-subscriber.cpp
@@ -48,10 +48,10 @@
 #include "util/notification-subscriber.hpp"
 #include "util/notification-stream.hpp"
 #include "simple-notification.hpp"
+#include "util/dummy-client-face.hpp"
 
 #include "boost-test.hpp"
-#include <boost/asio.hpp>
-#include "util/dummy-client-face.hpp"
+#include "../unit-test-time-fixture.hpp"
 
 namespace ndn {
 namespace util {
@@ -59,14 +59,14 @@
 
 BOOST_AUTO_TEST_SUITE(UtilNotificationSubscriber)
 
-class EndToEndFixture
+class EndToEndFixture : public ndn::tests::UnitTestTimeFixture
 {
 public:
   EndToEndFixture()
     : streamPrefix("ndn:/NotificationSubscriberTest")
-    , publisherFace(makeDummyClientFace(ioService))
+    , publisherFace(makeDummyClientFace(io))
     , notificationStream(*publisherFace, streamPrefix, publisherKeyChain)
-    , subscriberFace(makeDummyClientFace(ioService))
+    , subscriberFace(makeDummyClientFace(io))
     , subscriber(*subscriberFace, streamPrefix, time::seconds(1))
   {
   }
@@ -80,7 +80,7 @@
     SimpleNotification notification(msg);
     notificationStream.postNotification(notification);
 
-    publisherFace->processEvents(time::milliseconds(100));
+    advanceClocks(time::milliseconds(1));
 
     BOOST_REQUIRE_EQUAL(publisherFace->sentDatas.size(), 1);
 
@@ -149,7 +149,6 @@
   }
 
 protected:
-  boost::asio::io_service ioService;
   Name streamPrefix;
   shared_ptr<DummyClientFace> publisherFace;
   ndn::KeyChain publisherKeyChain;
@@ -178,34 +177,34 @@
 
   // not received when subscriber is not running
   this->deliverNotification("n1");
-  subscriberFace->processEvents(time::milliseconds(100));
+  advanceClocks(time::milliseconds(1));
   BOOST_CHECK(lastNotification.getMessage().empty());
   BOOST_CHECK_EQUAL(subscriberFace->sentInterests.size(), 0);
 
   subscriberFace->sentInterests.clear();
   subscriber.start();
-  subscriberFace->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1));
   BOOST_REQUIRE_EQUAL(subscriber.isRunning(), true);
   BOOST_CHECK(this->hasInitialRequest());
 
   // respond to initial request
   subscriberFace->sentInterests.clear();
   this->deliverNotification("n2");
-  subscriberFace->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1));
   BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n2");
   BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
 
   // respond to continuation request
   subscriberFace->sentInterests.clear();
   this->deliverNotification("n3");
-  subscriberFace->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1));
   BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n3");
   BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
 
   // timeout
   subscriberFace->sentInterests.clear();
   lastNotification.setMessage("");
-  subscriberFace->processEvents(2 * subscriber.getInterestLifetime());
+  advanceClocks(subscriber.getInterestLifetime(), 2);
   BOOST_CHECK(lastNotification.getMessage().empty());
   BOOST_CHECK_EQUAL(hasTimeout, true);
   BOOST_CHECK(this->hasInitialRequest());
@@ -218,7 +217,7 @@
   subscriberFace->receive(wrongData);
   subscriberFace->sentInterests.clear();
   lastNotification.setMessage("");
-  subscriberFace->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1));
   BOOST_CHECK(lastNotification.getMessage().empty());
   BOOST_CHECK_EQUAL(lastDecodeErrorData.getName(), wrongName);
   BOOST_CHECK(this->hasInitialRequest());
@@ -227,7 +226,7 @@
   subscriberFace->sentInterests.clear();
   lastNotification.setMessage("");
   this->deliverNotification("\x07n4");
-  subscriberFace->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1));
   BOOST_CHECK(lastNotification.getMessage().empty());
   BOOST_CHECK(this->hasInitialRequest());
 
@@ -235,7 +234,7 @@
   subscriber.onNotification += bind(&EndToEndFixture::clearNotificationHandlers, this);
   subscriberFace->sentInterests.clear();
   this->deliverNotification("n5");
-  subscriberFace->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1));
   BOOST_CHECK_EQUAL(subscriberFace->sentInterests.size(), 0);
 }
 
diff --git a/tests/unit-tests/util/segment-fetcher.cpp b/tests/unit-tests/util/segment-fetcher.cpp
index 3a9fc5f..15d7831 100644
--- a/tests/unit-tests/util/segment-fetcher.cpp
+++ b/tests/unit-tests/util/segment-fetcher.cpp
@@ -24,6 +24,7 @@
 #include "boost-test.hpp"
 #include "util/dummy-client-face.hpp"
 #include "security/key-chain.hpp"
+#include "../unit-test-time-fixture.hpp"
 
 namespace ndn {
 namespace util {
@@ -31,11 +32,11 @@
 
 BOOST_AUTO_TEST_SUITE(UtilSegmentFetcher)
 
-class Fixture
+class Fixture : public ndn::tests::UnitTestTimeFixture
 {
 public:
   Fixture()
-    : face(makeDummyClientFace())
+    : face(makeDummyClientFace(io))
     , nErrors(0)
     , nDatas(0)
     , dataSize(0)
@@ -89,10 +90,9 @@
                         bind(&Fixture::onData, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  face->processEvents(time::seconds(1));
+  advanceClocks(time::milliseconds(1), 99);
 
-  BOOST_CHECK_EQUAL(nErrors, 1);
-  BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::INTEREST_TIMEOUT));
+  BOOST_CHECK_EQUAL(nErrors, 0);
   BOOST_CHECK_EQUAL(nDatas, 0);
   BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
   BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
@@ -101,21 +101,27 @@
   BOOST_CHECK_EQUAL(interest.getName(), "/hello/world");
   BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
   BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
+
+  advanceClocks(time::milliseconds(1), 2);
+
+  BOOST_CHECK_EQUAL(nErrors, 1);
+  BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::INTEREST_TIMEOUT));
+  BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
+  BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
 }
 
 
 BOOST_FIXTURE_TEST_CASE(Basic, Fixture)
 {
-
   SegmentFetcher::fetch(*face, Interest("/hello/world", time::seconds(1000)),
                         DontVerifySegment(),
                         bind(&Fixture::onData, this, _1),
                         bind(&Fixture::onError, this, _1));
 
+  advanceClocks(time::milliseconds(1), 10);
 
-  face->processEvents(time::milliseconds(-100));
   face->receive(*makeData("/hello/world/version0", 0, true));
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
 
   BOOST_CHECK_EQUAL(nErrors, 0);
   BOOST_CHECK_EQUAL(nDatas, 1);
@@ -139,7 +145,7 @@
                         bind(&Fixture::onData, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
 
   const uint8_t buffer[] = "Hello, world!";
 
@@ -148,7 +154,7 @@
   keyChain.sign(*data);
 
   face->receive(*data);
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
 
   BOOST_CHECK_EQUAL(nErrors, 1);
   BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::DATA_HAS_NO_SEGMENT));
@@ -169,9 +175,9 @@
                         bind(&Fixture::onData, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
   face->receive(*makeData("/hello/world/version0", 0, true));
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
 
   BOOST_CHECK_EQUAL(nErrors, 1);
   BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::SEGMENT_VERIFICATION_FAIL));
@@ -188,16 +194,16 @@
                         bind(&Fixture::onData, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
   face->receive(*makeData("/hello/world/version0", 0, false));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
   face->receive(*makeData("/hello/world/version0", 1, false));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
   face->receive(*makeData("/hello/world/version0", 2, true));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
 
   BOOST_CHECK_EQUAL(nErrors, 0);
   BOOST_CHECK_EQUAL(nDatas, 1);
@@ -238,19 +244,19 @@
                         bind(&Fixture::onData, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
   face->receive(*makeData("/hello/world/version0", 1, false));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
   face->receive(*makeData("/hello/world/version0", 0, false));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
   face->receive(*makeData("/hello/world/version0", 1, false));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
   face->receive(*makeData("/hello/world/version0", 2, true));
 
-  face->processEvents(time::milliseconds(-100));
+  advanceClocks(time::milliseconds(1), 10);
 
   BOOST_CHECK_EQUAL(nErrors, 0);
   BOOST_CHECK_EQUAL(nDatas, 1);
diff --git a/tests/unit-tests/util/test-scheduler.cpp b/tests/unit-tests/util/test-scheduler.cpp
index 04d4f99..c8c8179 100644
--- a/tests/unit-tests/util/test-scheduler.cpp
+++ b/tests/unit-tests/util/test-scheduler.cpp
@@ -22,253 +22,186 @@
 #include "util/scheduler.hpp"
 
 #include "boost-test.hpp"
+#include "../unit-test-time-fixture.hpp"
 
 namespace ndn {
+namespace tests {
 
-BOOST_AUTO_TEST_SUITE(UtilTestScheduler)
+BOOST_FIXTURE_TEST_SUITE(UtilTestScheduler, UnitTestTimeFixture)
 
-struct SchedulerFixture
+BOOST_AUTO_TEST_CASE(Events)
 {
-  SchedulerFixture()
-    : count1(0)
-    , count2(0)
-    , count3(0)
-  {
-  }
-
-  void
-  event1()
-  {
-    BOOST_CHECK_EQUAL(count3, 1);
-    ++count1;
-  }
-
-  void
-  event2()
-  {
-    ++count2;
-  }
-
-  void
-  event3()
-  {
-    BOOST_CHECK_EQUAL(count1, 0);
-    ++count3;
-  }
-
-  int count1;
-  int count2;
-  int count3;
-};
-
-BOOST_FIXTURE_TEST_CASE(Events, SchedulerFixture)
-{
-  boost::asio::io_service io;
+  size_t count1 = 0;
+  size_t count2 = 0;
 
   Scheduler scheduler(io);
-  scheduler.scheduleEvent(time::milliseconds(500), bind(&SchedulerFixture::event1, this));
+  scheduler.scheduleEvent(time::milliseconds(500), [&] {
+      ++count1;
+      BOOST_CHECK_EQUAL(count2, 1);
+    });
 
-  EventId i = scheduler.scheduleEvent(time::seconds(1), bind(&SchedulerFixture::event2, this));
+  EventId i = scheduler.scheduleEvent(time::seconds(1), [&] {
+      BOOST_ERROR("This event should not have been fired");
+    });
   scheduler.cancelEvent(i);
 
-  scheduler.scheduleEvent(time::milliseconds(250), bind(&SchedulerFixture::event3, this));
+  scheduler.scheduleEvent(time::milliseconds(250), [&] {
+      BOOST_CHECK_EQUAL(count1, 0);
+      ++count2;
+    });
 
-  i = scheduler.scheduleEvent(time::milliseconds(50), bind(&SchedulerFixture::event2, this));
+  i = scheduler.scheduleEvent(time::milliseconds(50), [&] {
+      BOOST_ERROR("This event should not have been fired");
+    });
   scheduler.cancelEvent(i);
 
-  io.run();
-
+  advanceClocks(time::milliseconds(1), 1000);
   BOOST_CHECK_EQUAL(count1, 1);
-  BOOST_CHECK_EQUAL(count2, 0);
-  BOOST_CHECK_EQUAL(count3, 1);
+  BOOST_CHECK_EQUAL(count2, 1);
 }
 
 BOOST_AUTO_TEST_CASE(CancelEmptyEvent)
 {
-  boost::asio::io_service io;
   Scheduler scheduler(io);
 
   EventId i;
   scheduler.cancelEvent(i);
 }
 
-struct SelfCancelFixture
+BOOST_AUTO_TEST_CASE(SelfCancel)
 {
-  SelfCancelFixture()
-    : m_scheduler(m_io)
-  {
-  }
+  Scheduler scheduler(io);
 
-  void
-  cancelSelf()
-  {
-    m_scheduler.cancelEvent(m_selfEventId);
-  }
+  EventId selfEventId;
+  selfEventId = scheduler.scheduleEvent(time::milliseconds(100), [&] {
+      scheduler.cancelEvent(selfEventId);
+    });
 
-  boost::asio::io_service m_io;
-  Scheduler m_scheduler;
-  EventId m_selfEventId;
-};
-
-BOOST_FIXTURE_TEST_CASE(SelfCancel, SelfCancelFixture)
-{
-  m_selfEventId = m_scheduler.scheduleEvent(time::milliseconds(100),
-                                            bind(&SelfCancelFixture::cancelSelf, this));
-
-  BOOST_REQUIRE_NO_THROW(m_io.run());
+  BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(100), 10));
 }
 
-struct SelfRescheduleFixture
+class SelfRescheduleFixture : public UnitTestTimeFixture
 {
+public:
   SelfRescheduleFixture()
-    : m_scheduler(m_io)
-    , m_count(0)
+    : scheduler(io)
+    , count(0)
   {
   }
 
   void
   reschedule()
   {
-    EventId eventId = m_scheduler.scheduleEvent(time::milliseconds(100),
-                                                bind(&SelfRescheduleFixture::reschedule, this));
-    m_scheduler.cancelEvent(m_selfEventId);
-    m_selfEventId = eventId;
+    EventId eventId = scheduler.scheduleEvent(time::milliseconds(100),
+                                              bind(&SelfRescheduleFixture::reschedule, this));
+    scheduler.cancelEvent(selfEventId);
+    selfEventId = eventId;
 
-    if(m_count < 5)
-      m_count++;
+    if (count < 5)
+      count++;
     else
-      m_scheduler.cancelEvent(m_selfEventId);
+      scheduler.cancelEvent(selfEventId);
   }
 
   void
   reschedule2()
   {
-    m_scheduler.cancelEvent(m_selfEventId);
+    scheduler.cancelEvent(selfEventId);
 
-
-    if(m_count < 5)
-      {
-        m_selfEventId = m_scheduler.scheduleEvent(time::milliseconds(100),
-                                                  bind(&SelfRescheduleFixture::reschedule2, this));
-        m_count++;
-      }
-  }
-
-  void
-  doNothing()
-  {
-    m_count++;
+    if (count < 5)  {
+      selfEventId = scheduler.scheduleEvent(time::milliseconds(100),
+                                            bind(&SelfRescheduleFixture::reschedule2, this));
+      count++;
+    }
   }
 
   void
   reschedule3()
   {
-    m_scheduler.cancelEvent(m_selfEventId);
+    scheduler.cancelEvent(selfEventId);
 
-    m_scheduler.scheduleEvent(time::milliseconds(100),
-                              bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::milliseconds(100),
-                              bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::milliseconds(100),
-                              bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::milliseconds(100),
-                              bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::milliseconds(100),
-                              bind(&SelfRescheduleFixture::doNothing, this));
-    m_scheduler.scheduleEvent(time::milliseconds(100),
-                              bind(&SelfRescheduleFixture::doNothing, this));
+    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
+    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
+    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
+    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
+    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
+    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
   }
 
-  boost::asio::io_service m_io;
-  Scheduler m_scheduler;
-  EventId m_selfEventId;
-  int m_count;
-
+  Scheduler scheduler;
+  EventId selfEventId;
+  size_t count;
 };
 
 BOOST_FIXTURE_TEST_CASE(Reschedule, SelfRescheduleFixture)
 {
-  m_selfEventId = m_scheduler.scheduleEvent(time::seconds(0),
-                                            bind(&SelfRescheduleFixture::reschedule, this));
+  selfEventId = scheduler.scheduleEvent(time::seconds(0),
+                                        bind(&SelfRescheduleFixture::reschedule, this));
 
-  BOOST_REQUIRE_NO_THROW(m_io.run());
+  BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(10), 1000));
 
-  BOOST_CHECK_EQUAL(m_count, 5);
+  BOOST_CHECK_EQUAL(count, 5);
 }
 
 BOOST_FIXTURE_TEST_CASE(Reschedule2, SelfRescheduleFixture)
 {
-  m_selfEventId = m_scheduler.scheduleEvent(time::seconds(0),
-                                            bind(&SelfRescheduleFixture::reschedule2, this));
+  selfEventId = scheduler.scheduleEvent(time::seconds(0),
+                                        bind(&SelfRescheduleFixture::reschedule2, this));
 
-  BOOST_REQUIRE_NO_THROW(m_io.run());
+  BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(10), 1000));
 
-  BOOST_CHECK_EQUAL(m_count, 5);
+  BOOST_CHECK_EQUAL(count, 5);
 }
 
 BOOST_FIXTURE_TEST_CASE(Reschedule3, SelfRescheduleFixture)
 {
-  m_selfEventId = m_scheduler.scheduleEvent(time::seconds(0),
-                                            bind(&SelfRescheduleFixture::reschedule3, this));
+  selfEventId = scheduler.scheduleEvent(time::seconds(0),
+                                        bind(&SelfRescheduleFixture::reschedule3, this));
 
-  BOOST_REQUIRE_NO_THROW(m_io.run());
+  BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(10), 1000));
 
-  BOOST_CHECK_EQUAL(m_count, 6);
+  BOOST_CHECK_EQUAL(count, 6);
 }
 
 
-struct CancelAllFixture
+struct CancelAllFixture : public UnitTestTimeFixture
 {
   CancelAllFixture()
-    : m_scheduler(m_io)
-    , m_count(0)
+    : scheduler(io)
+    , count(0)
   {
   }
 
   void
-  cancelAll()
-  {
-    m_scheduler.cancelAllEvents();
-  }
-
-  void
   event()
   {
-    ++m_count;
+    ++count;
 
-    m_scheduler.scheduleEvent(time::seconds(1),
-                              bind(&CancelAllFixture::event, this));
+    scheduler.scheduleEvent(time::seconds(1), [&] { event(); });
   }
 
-  void
-  abort()
-  {
-    m_io.stop();
-  }
-
-  boost::asio::io_service m_io;
-  Scheduler m_scheduler;
-  uint32_t m_count;
+  Scheduler scheduler;
+  uint32_t count;
 };
 
 
 BOOST_FIXTURE_TEST_CASE(CancelAll, CancelAllFixture)
 {
-  m_scheduler.scheduleEvent(time::milliseconds(500),
-                            bind(&CancelAllFixture::cancelAll, this));
+  scheduler.scheduleEvent(time::milliseconds(500), [&] { scheduler.cancelAllEvents(); });
 
-  m_scheduler.scheduleEvent(time::seconds(1),
-                            bind(&CancelAllFixture::event, this));
+  scheduler.scheduleEvent(time::seconds(1), [&] { event(); });
 
-  m_scheduler.scheduleEvent(time::seconds(3),
-                            bind(&CancelAllFixture::abort, this));
+  scheduler.scheduleEvent(time::seconds(3), [] {
+      BOOST_ERROR("This event should have been cancelled" );
+    });
 
-  BOOST_REQUIRE_NO_THROW(m_io.run());
+  advanceClocks(time::milliseconds(100), 100);
 
-  BOOST_CHECK_EQUAL(m_count, 0);
+  BOOST_CHECK_EQUAL(count, 0);
 }
 
 
 BOOST_AUTO_TEST_SUITE_END()
 
+} // namespace tests
 } // namespace ndn
