diff --git a/tests/identity-management-fixture.cpp b/tests/identity-management-fixture.cpp
new file mode 100644
index 0000000..007b35b
--- /dev/null
+++ b/tests/identity-management-fixture.cpp
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2017 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "identity-management-fixture.hpp"
+
+#include <ndn-cxx/util/io.hpp>
+#include <boost/filesystem.hpp>
+
+namespace ndn {
+namespace tests {
+
+IdentityManagementFixture::IdentityManagementFixture()
+  : m_keyChain("pib-memory:", "tpm-memory:")
+{
+  m_keyChain.createIdentity("/DEFAULT");
+}
+
+IdentityManagementFixture::~IdentityManagementFixture()
+{
+  boost::system::error_code ec;
+  for (const auto& certFile : m_certFiles) {
+    boost::filesystem::remove(certFile, ec); // ignore error
+  }
+}
+
+bool
+IdentityManagementFixture::addIdentity(const Name& identity, const ndn::KeyParams& params)
+{
+  try {
+    m_keyChain.createIdentity(identity, params);
+    return true;
+  }
+  catch (const std::runtime_error&) {
+    return false;
+  }
+}
+
+bool
+IdentityManagementFixture::saveIdentityCertificate(const Name& identity, const std::string& filename, bool wantAdd)
+{
+  ndn::security::v2::Certificate cert;
+  try {
+    cert = m_keyChain.getPib().getIdentity(identity).getDefaultKey().getDefaultCertificate();
+  }
+  catch (const ndn::security::Pib::Error&) {
+    if (wantAdd && this->addIdentity(identity)) {
+      return this->saveIdentityCertificate(identity, filename, false);
+    }
+    return false;
+  }
+
+  m_certFiles.push_back(filename);
+  try {
+    ndn::io::save(cert, filename);
+    return true;
+  }
+  catch (const ndn::io::Error&) {
+    return false;
+  }
+}
+
+} // namespace tests
+} // namespace ndn
diff --git a/tests/identity-management-fixture.hpp b/tests/identity-management-fixture.hpp
new file mode 100644
index 0000000..2776eb0
--- /dev/null
+++ b/tests/identity-management-fixture.hpp
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2017 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
+#define NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
+
+#include "common.hpp"
+
+#include "unit-test-time-fixture.hpp"
+
+namespace ndn {
+namespace tests {
+
+/** \brief a fixture that cleans up KeyChain identities and certificate files upon destruction
+ */
+class IdentityManagementFixture
+{
+public:
+  IdentityManagementFixture();
+
+  /** \brief deletes saved certificate files
+   */
+  ~IdentityManagementFixture();
+
+  /** \brief add identity
+   *  \return whether successful
+   */
+  bool
+  addIdentity(const Name& identity,
+              const ndn::KeyParams& params = ndn::KeyChain::getDefaultKeyParams());
+
+  /** \brief save identity certificate to a file
+   *  \param identity identity name
+   *  \param filename file name, should be writable
+   *  \param wantAdd if true, add new identity when necessary
+   *  \return whether successful
+   */
+  bool
+  saveIdentityCertificate(const Name& identity, const std::string& filename, bool wantAdd = false);
+
+protected:
+  ndn::KeyChain m_keyChain;
+
+private:
+  std::vector<std::string> m_certFiles;
+};
+
+/** \brief convenience base class for inheriting from both UnitTestTimeFixture
+ *         and IdentityManagementFixture
+ */
+class IdentityManagementTimeFixture : public UnitTestTimeFixture
+                                    , public IdentityManagementFixture
+{
+};
+
+} // namespace tests
+} // namespace ndn
+
+#endif // NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
diff --git a/tests/unit-test-time-fixture.hpp b/tests/unit-test-time-fixture.hpp
index 03421f8..f172cff 100644
--- a/tests/unit-test-time-fixture.hpp
+++ b/tests/unit-test-time-fixture.hpp
@@ -1,28 +1,27 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2014 Regents of the University of California.
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2017 University of California, Los Angeles
  *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
  *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
  *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
  *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #ifndef NDN_TESTS_UNIT_TESTS_UNIT_TEST_TIME_FIXTURE_HPP
 #define NDN_TESTS_UNIT_TESTS_UNIT_TEST_TIME_FIXTURE_HPP
 
 #include <ndn-cxx/util/time-unit-test-clock.hpp>
+
 #include <boost/asio.hpp>
 
 namespace ndn {
diff --git a/tests/unit-tests/dummy-forwarder.cpp b/tests/unit-tests/dummy-forwarder.cpp
new file mode 100644
index 0000000..224dcd3
--- /dev/null
+++ b/tests/unit-tests/dummy-forwarder.cpp
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2017 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "dummy-forwarder.hpp"
+
+#include <boost/asio/io_service.hpp>
+
+namespace ndn {
+namespace chronosync {
+
+DummyForwarder::DummyForwarder(boost::asio::io_service& io, KeyChain& keyChain)
+  : m_io(io)
+  , m_keyChain(keyChain)
+{
+}
+
+Face&
+DummyForwarder::addFace()
+{
+  auto face = std::make_shared<util::DummyClientFace>(m_io, m_keyChain,
+                                                      util::DummyClientFace::Options{true, true});
+  face->onSendInterest.connect([this, face] (const Interest& interest) {
+      Interest i(interest);
+      for (auto& otherFace : m_faces) {
+        if (&*face == &*otherFace) {
+          continue;
+        }
+        m_io.post([=] { otherFace->receive(i); });
+      }
+    });
+  face->onSendData.connect([this, face] (const Data& data) {
+      Data d(data);
+      for (auto& otherFace : m_faces) {
+        if (&*face == &*otherFace) {
+          continue;
+        }
+        m_io.post([=] { otherFace->receive(d); });
+      }
+    });
+
+  face->onSendNack.connect([this, face] (const lp::Nack& nack) {
+      lp::Nack n(nack);
+      for (auto& otherFace : m_faces) {
+        if (&*face == &*otherFace) {
+          continue;
+        }
+        m_io.post([=] { otherFace->receive(n); });
+      }
+    });
+
+  m_faces.push_back(face);
+  return *face;
+}
+
+} // namespace chronosync
+} // namespace ndn
diff --git a/tests/unit-tests/dummy-forwarder.hpp b/tests/unit-tests/dummy-forwarder.hpp
new file mode 100644
index 0000000..3e7d9b3
--- /dev/null
+++ b/tests/unit-tests/dummy-forwarder.hpp
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2017 University of California, Los Angeles
+ *
+ * This file is part of ChronoSync, synchronization library for distributed realtime
+ * applications for NDN.
+ *
+ * ChronoSync is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ChronoSync, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/data.hpp>
+#include <ndn-cxx/lp/nack.hpp>
+#include <ndn-cxx/util/dummy-client-face.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+
+#ifndef NDN_CHRONOSYNC_UNIT_TESTS_DUMMY_FORWARDER_HPP
+#define NDN_CHRONOSYNC_UNIT_TESTS_DUMMY_FORWARDER_HPP
+
+namespace ndn {
+namespace chronosync {
+
+/**
+ * @brief Very basic implementation of the dummy forwarder
+ *
+ * Interests expressed by any added face, will be forwarded to all other faces.
+ * Similarly, any pushed data, will be pushed to all other faces.
+ */
+class DummyForwarder
+{
+public:
+  DummyForwarder(boost::asio::io_service& io, KeyChain& keyChain);
+
+  Face&
+  addFace();
+
+  Face&
+  getFace(size_t nFace)
+  {
+    return *m_faces.at(nFace);
+  }
+
+private:
+  boost::asio::io_service& m_io;
+  KeyChain& m_keyChain;
+  std::vector<shared_ptr<util::DummyClientFace>> m_faces;
+};
+
+} // namespace chronosync
+} // namespace ndn
+
+#endif // NDN_CHRONOSYNC_UNIT_TESTS_DUMMY_FORWARDER_HPP
diff --git a/tests/unit-tests/test-interest-table.cpp b/tests/unit-tests/test-interest-table.cpp
index 0f0c95d..be0f289 100644
--- a/tests/unit-tests/test-interest-table.cpp
+++ b/tests/unit-tests/test-interest-table.cpp
@@ -37,37 +37,36 @@
     Name interestName1;
     digest1 = ndn::util::Sha256::computeDigest(origin, 1);
     interestName1.append(prefix).append(name::Component(digest1));
-    interest1 = make_shared<Interest>(interestName1);
-    interest1->setInterestLifetime(time::milliseconds(100));
+
+    interest1 = Interest(interestName1);
+    interest1.setInterestLifetime(time::milliseconds(100));
 
     Name interestName2;
     digest2 = ndn::util::Sha256::computeDigest(origin, 2);
     interestName2.append(prefix).append(name::Component(digest2));
-    interest2 = make_shared<Interest>(interestName2);
-    interest2->setInterestLifetime(time::milliseconds(100));
+    interest2 = Interest(interestName2);
+    interest2.setInterestLifetime(time::milliseconds(100));
 
     Name interestName3;
     digest3 = ndn::util::Sha256::computeDigest(origin, 3);
     interestName3.append(prefix).append(name::Component(digest3));
-    interest3 = make_shared<Interest>(interestName3);
-    interest3->setInterestLifetime(time::milliseconds(100));
+    interest3 = Interest(interestName3);
+    interest3.setInterestLifetime(time::milliseconds(100));
   }
 
   void
-  insert(InterestTable& table,
-         shared_ptr<Interest> interest,
-         ndn::ConstBufferPtr digest)
+  insert(InterestTable& table, const Interest& interest, ndn::ConstBufferPtr digest)
   {
     table.insert(interest, digest);
   }
 
-  shared_ptr<Interest> interest1;
+  Interest interest1;
   ndn::ConstBufferPtr digest1;
 
-  shared_ptr<Interest> interest2;
+  Interest interest2;
   ndn::ConstBufferPtr digest2;
 
-  shared_ptr<Interest> interest3;
+  Interest interest3;
   ndn::ConstBufferPtr digest3;
 };
 
diff --git a/tests/unit-tests/test-logic.cpp b/tests/unit-tests/test-logic.cpp
index 342af4c..a243bb0 100644
--- a/tests/unit-tests/test-logic.cpp
+++ b/tests/unit-tests/test-logic.cpp
@@ -18,20 +18,22 @@
  */
 
 #include "logic.hpp"
-#include "../unit-test-time-fixture.hpp"
-#include <ndn-cxx/util/dummy-client-face.hpp>
+
 #include "boost-test.hpp"
+#include "../identity-management-fixture.hpp"
+
+#include "dummy-forwarder.hpp"
 
 namespace chronosync {
 namespace test {
 
 using std::vector;
-using ndn::util::DummyClientFace;
+using ndn::chronosync::DummyForwarder;
 
 class Handler
 {
 public:
-  Handler(DummyClientFace& face,
+  Handler(ndn::Face& face,
           const Name& syncPrefix,
           const Name& userPrefix)
     : logic(face,
@@ -66,64 +68,30 @@
   std::map<Name, SeqNo> map;
 };
 
-class LogicFixture : public ndn::tests::UnitTestTimeFixture
+class LogicFixture : public ndn::tests::IdentityManagementTimeFixture
 {
 public:
   LogicFixture()
     : syncPrefix("/ndn/broadcast/sync")
+    , fw(io, m_keyChain)
   {
     syncPrefix.appendVersion();
     userPrefix[0] = Name("/user0");
     userPrefix[1] = Name("/user1");
     userPrefix[2] = Name("/user2");
     userPrefix[3] = Name("/user3");
-
-    faces[0].reset(new DummyClientFace(io, {true, true}));
-    faces[1].reset(new DummyClientFace(io, {true, true}));
-    faces[2].reset(new DummyClientFace(io, {true, true}));
-    faces[3].reset(new DummyClientFace(io, {true, true}));
-
-    for (int i = 0; i < 4; i++) {
-      readInterestOffset[i] = 0;
-      readDataOffset[i] = 0;
-    }
-  }
-
-  void
-  passPacket()
-  {
-    for (int i = 0; i < 4; i++)
-      checkFace(i);
-  }
-
-  void
-  checkFace(int sender)
-  {
-    while (faces[sender]->sentInterests.size() > readInterestOffset[sender]) {
-      for (int i = 0; i < 4; i++) {
-        if (sender != i)
-          faces[i]->receive(faces[sender]->sentInterests[readInterestOffset[sender]]);
-      }
-      readInterestOffset[sender]++;
-    }
-    while (faces[sender]->sentData.size() > readDataOffset[sender]) {
-      for (int i = 0; i < 4; i++) {
-        if (sender != i)
-          faces[i]->receive(faces[sender]->sentData[readDataOffset[sender]]);
-      }
-      readDataOffset[sender]++;
-    }
   }
 
 public:
   Name syncPrefix;
   Name userPrefix[4];
 
-  std::unique_ptr<DummyClientFace> faces[4];
+  DummyForwarder fw;
+  // std::unique_ptr<DummyClientFace> faces[4];
   shared_ptr<Handler> handler[4];
 
-  size_t readInterestOffset[4];
-  size_t readDataOffset[4];
+  // size_t readInterestOffset[4];
+  // size_t readDataOffset[4];
 };
 
 BOOST_FIXTURE_TEST_SUITE(LogicTests, LogicFixture)
@@ -137,156 +105,120 @@
 {
   Name syncPrefix("/ndn/broadcast/sync");
   Name userPrefix("/user");
-  DummyClientFace face(io, {true, true});
-  BOOST_REQUIRE_NO_THROW(Logic(face, syncPrefix, userPrefix,
-                               bind(onUpdate, _1)));
+  ndn::util::DummyClientFace face(io, {true, true});
+  BOOST_REQUIRE_NO_THROW(Logic(face, syncPrefix, userPrefix, bind(onUpdate, _1)));
 }
 
 BOOST_AUTO_TEST_CASE(TwoBasic)
 {
-  handler[0] = make_shared<Handler>(ref(*faces[0]), syncPrefix, userPrefix[0]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[0] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[0]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[1] = make_shared<Handler>(ref(*faces[1]), syncPrefix, userPrefix[1]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[1] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[1]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
   handler[0]->updateSeqNo(1);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
+
   BOOST_CHECK_EQUAL(handler[1]->map[handler[0]->logic.getSessionName()], 1);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
   handler[0]->updateSeqNo(2);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[0]->logic.getSessionName()], 2);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
   handler[1]->updateSeqNo(2);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[1]->logic.getSessionName()], 2);
 }
 
 BOOST_AUTO_TEST_CASE(ThreeBasic)
 {
-  handler[0] = make_shared<Handler>(ref(*faces[0]), syncPrefix, userPrefix[0]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[0] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[0]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[1] = make_shared<Handler>(ref(*faces[1]), syncPrefix, userPrefix[1]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[1] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[1]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[2] = make_shared<Handler>(ref(*faces[2]), syncPrefix, userPrefix[2]);
-  advanceClocks(ndn::time::milliseconds(10), 20);
+  handler[2] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[2]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
   handler[0]->updateSeqNo(1);
 
-  for (int i = 0; i < 70; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[0]->logic.getSessionName()], 1);
   BOOST_CHECK_EQUAL(handler[2]->map[handler[0]->logic.getSessionName()], 1);
 
   handler[1]->updateSeqNo(2);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[1]->logic.getSessionName()], 2);
   BOOST_CHECK_EQUAL(handler[2]->map[handler[1]->logic.getSessionName()], 2);
 
   handler[2]->updateSeqNo(4);
 
-  for (int i = 0; i < 100; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[2]->logic.getSessionName()], 4);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[2]->logic.getSessionName()], 4);
 }
 
 BOOST_AUTO_TEST_CASE(ResetRecover)
 {
-  handler[0] = make_shared<Handler>(ref(*faces[0]), syncPrefix, userPrefix[0]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[0] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[0]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[1] = make_shared<Handler>(ref(*faces[1]), syncPrefix, userPrefix[1]);
-  advanceClocks(ndn::time::milliseconds(10), 30);
+  handler[1] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[1]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
   handler[0]->updateSeqNo(1);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[0]->logic.getSessionName()], 1);
 
   handler[1]->updateSeqNo(2);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[1]->logic.getSessionName()], 2);
 
-  advanceClocks(ndn::time::milliseconds(10), 10);
-  handler[2] = make_shared<Handler>(ref(*faces[2]), syncPrefix, userPrefix[2]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
+  handler[2] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[2]);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[2]->map[handler[0]->logic.getSessionName()], 1);
   BOOST_CHECK_EQUAL(handler[2]->map[handler[1]->logic.getSessionName()], 2);
 
   handler[2]->updateSeqNo(4);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[2]->logic.getSessionName()], 4);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[2]->logic.getSessionName()], 4);
 }
 
 BOOST_AUTO_TEST_CASE(RecoverConflict)
 {
-  handler[0] = make_shared<Handler>(ref(*faces[0]), syncPrefix, userPrefix[0]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[0] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[0]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[1] = make_shared<Handler>(ref(*faces[1]), syncPrefix, userPrefix[1]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[1] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[1]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[2] = make_shared<Handler>(ref(*faces[2]), syncPrefix, userPrefix[2]);
-  advanceClocks(ndn::time::milliseconds(10), 30);
+  handler[2] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[2]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
   handler[0]->updateSeqNo(1);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[0]->logic.getSessionName()], 1);
   BOOST_CHECK_EQUAL(handler[2]->map[handler[0]->logic.getSessionName()], 1);
 
   handler[1]->updateSeqNo(2);
   handler[2]->updateSeqNo(4);
 
-  for (int i = 0; i < 75; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[1]->logic.getSessionName()], 2);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[2]->logic.getSessionName()], 4);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[2]->logic.getSessionName()], 4);
@@ -295,34 +227,28 @@
 
 BOOST_AUTO_TEST_CASE(PartitionRecover)
 {
-  handler[0] = make_shared<Handler>(ref(*faces[0]), syncPrefix, userPrefix[0]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[0] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[0]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[1] = make_shared<Handler>(ref(*faces[1]), syncPrefix, userPrefix[1]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[1] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[1]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[2] = make_shared<Handler>(ref(*faces[2]), syncPrefix, userPrefix[2]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[2] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[2]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[3] = make_shared<Handler>(ref(*faces[3]), syncPrefix, userPrefix[3]);
-  advanceClocks(ndn::time::milliseconds(10), 30);
+  handler[3] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[3]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
   handler[0]->updateSeqNo(1);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[0]->logic.getSessionName()], 1);
   BOOST_CHECK_EQUAL(handler[2]->map[handler[0]->logic.getSessionName()], 1);
   BOOST_CHECK_EQUAL(handler[3]->map[handler[0]->logic.getSessionName()], 1);
 
   handler[2]->updateSeqNo(2);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[2]->logic.getSessionName()], 2);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[2]->logic.getSessionName()], 2);
   BOOST_CHECK_EQUAL(handler[3]->map[handler[2]->logic.getSessionName()], 2);
@@ -331,20 +257,14 @@
 
   handler[1]->updateSeqNo(3);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[1]->logic.getSessionName()], 3);
   handler[2]->map[handler[1]->logic.getSessionName()] = 0;
   handler[3]->map[handler[1]->logic.getSessionName()] = 0;
 
   handler[3]->updateSeqNo(4);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[2]->map[handler[3]->logic.getSessionName()], 4);
   handler[0]->map[handler[3]->logic.getSessionName()] = 0;
   handler[1]->map[handler[3]->logic.getSessionName()] = 0;
@@ -353,20 +273,14 @@
 
   handler[0]->updateSeqNo(5);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[0]->logic.getSessionName()], 5);
   BOOST_CHECK_EQUAL(handler[2]->map[handler[0]->logic.getSessionName()], 5);
   BOOST_CHECK_EQUAL(handler[3]->map[handler[0]->logic.getSessionName()], 5);
 
   handler[2]->updateSeqNo(6);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[2]->logic.getSessionName()], 6);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[2]->logic.getSessionName()], 6);
   BOOST_CHECK_EQUAL(handler[3]->map[handler[2]->logic.getSessionName()], 6);
@@ -374,49 +288,34 @@
 
 BOOST_AUTO_TEST_CASE(MultipleUserUnderOneLogic)
 {
-  handler[0] = make_shared<Handler>(ref(*faces[0]), syncPrefix, userPrefix[0]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[0] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[0]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
-  handler[1] = make_shared<Handler>(ref(*faces[1]), syncPrefix, userPrefix[2]);
-  advanceClocks(ndn::time::milliseconds(10), 10);
+  handler[1] = make_shared<Handler>(ref(fw.addFace()), syncPrefix, userPrefix[2]);
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
   handler[0]->logic.addUserNode(userPrefix[1]);
 
-  for (int i = 0; i < 20; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
 
   handler[0]->updateSeqNo(1);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[0]->logic.getSessionName()], 1);
 
   handler[0]->logic.updateSeqNo(2, userPrefix[1]);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[1]->map[handler[0]->logic.getSessionName(userPrefix[1])], 2);
 
   handler[1]->updateSeqNo(4);
 
-  for (int i = 0; i < 50; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(10), 100);
   BOOST_CHECK_EQUAL(handler[0]->map[handler[1]->logic.getSessionName()], 4);
 
   handler[0]->logic.removeUserNode(userPrefix[0]);
 
-  for (int i = 0; i < 100; i++) {
-    advanceClocks(ndn::time::milliseconds(2), 10);
-    passPacket();
-  }
+  advanceClocks(ndn::time::milliseconds(50), 100);
   BOOST_CHECK_EQUAL(handler[1]->logic.getSessionNames().size(), 2);
 }
 
diff --git a/tests/unit-tests/test-socket.cpp b/tests/unit-tests/test-socket.cpp
index 0c478ec..3fd0d26 100644
--- a/tests/unit-tests/test-socket.cpp
+++ b/tests/unit-tests/test-socket.cpp
@@ -18,9 +18,11 @@
  */
 
 #include "socket.hpp"
-#include "../unit-test-time-fixture.hpp"
-#include <ndn-cxx/util/dummy-client-face.hpp>
+
 #include "boost-test.hpp"
+#include "../unit-test-time-fixture.hpp"
+
+#include <ndn-cxx/util/dummy-client-face.hpp>
 
 namespace chronosync {
 namespace test {
@@ -30,7 +32,6 @@
 using std::map;
 using ndn::util::DummyClientFace;
 
-
 /**
  * @brief Emulate an app that use the Socket class
  *
@@ -54,12 +55,12 @@
   }
 
   void
-  set(const shared_ptr<const Data>& dataPacket)
+  set(const Data& dataPacket)
   {
     // std::cerr << "set Data" << std::endl;
-    Name dataName(dataPacket->getName());
-    string str2(reinterpret_cast<const char*>(dataPacket->getContent().value()),
-                dataPacket->getContent().value_size());
+    Name dataName(dataPacket.getName());
+    string str2(reinterpret_cast<const char*>(dataPacket.getContent().value()),
+                dataPacket.getContent().value_size());
     data.insert(make_pair(dataName, str2));
   }
 
@@ -71,11 +72,11 @@
   }
 
   void
-  setNum(const shared_ptr<const Data>& dataPacket)
+  setNum(const Data& dataPacket)
   {
     // std::cerr << "setNum Data" << std::endl;
-    size_t n = dataPacket->getContent().value_size() / 4;
-    const uint32_t* numbers = reinterpret_cast<const uint32_t*>(dataPacket->getContent().value());
+    size_t n = dataPacket.getContent().value_size() / 4;
+    const uint32_t* numbers = reinterpret_cast<const uint32_t*>(dataPacket.getContent().value());
     for (size_t i = 0; i < n; i++) {
       sum += numbers[i];
     }
@@ -99,7 +100,7 @@
     // std::cerr << "fetchAll" << std::endl;
     for (size_t i = 0; i < v.size(); i++) {
       for(SeqNo s = v[i].low; s <= v[i].high; ++s) {
-        socket.fetchData(v[i].session, s, [this] (const shared_ptr<const Data>& dataPacket) {
+        socket.fetchData(v[i].session, s, [this] (const Data& dataPacket) {
             this->set(dataPacket);
           });
       }
@@ -112,7 +113,7 @@
     // std::cerr << "fetchNumbers" << std::endl;
     for (size_t i = 0; i < v.size(); i++) {
       for(SeqNo s = v[i].low; s <= v[i].high; ++s) {
-        socket.fetchData(v[i].session, s, [this] (const shared_ptr<const Data>& dataPacket) {
+        socket.fetchData(v[i].session, s, [this] (const Data& dataPacket) {
             this->setNum(dataPacket);
           });
       }
diff --git a/tests/unit-tests/test-state.cpp b/tests/unit-tests/test-state.cpp
index ed88373..9e7ce58 100644
--- a/tests/unit-tests/test-state.cpp
+++ b/tests/unit-tests/test-state.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
 /*
- * Copyright (c) 2012-2014 University of California, Los Angeles
+ * Copyright (c) 2012-2017 University of California, Los Angeles
  *
  * This file is part of ChronoSync, synchronization library for distributed realtime
  * applications for NDN.
@@ -18,12 +18,13 @@
  */
 
 #include "state.hpp"
+
 #include "boost-test.hpp"
 
 namespace chronosync {
 namespace test {
 
-using boost::tuple;
+using std::tuple;
 
 BOOST_AUTO_TEST_SUITE(StateTests)
 
@@ -43,21 +44,21 @@
 
   tuple<bool, bool, SeqNo> result;
   result = state.update(info, 12);
-  BOOST_CHECK_EQUAL(result.get<0>(), true);
-  BOOST_CHECK_EQUAL(result.get<1>(), false);
-  BOOST_CHECK_EQUAL(result.get<2>(), 0);
+  BOOST_CHECK_EQUAL(std::get<0>(result), true);
+  BOOST_CHECK_EQUAL(std::get<1>(result), false);
+  BOOST_CHECK_EQUAL(std::get<2>(result), 0);
 
   BOOST_CHECK_NO_THROW(state.update(info, 12));
   result = state.update(info, 12);
-  BOOST_CHECK_EQUAL(result.get<0>(), false);
-  BOOST_CHECK_EQUAL(result.get<1>(), false);
-  BOOST_CHECK_EQUAL(result.get<2>(), 0);
+  BOOST_CHECK_EQUAL(std::get<0>(result), false);
+  BOOST_CHECK_EQUAL(std::get<1>(result), false);
+  BOOST_CHECK_EQUAL(std::get<2>(result), 0);
 
   BOOST_CHECK_NO_THROW(state.update(info, 11));
   result = state.update(info, 11);
-  BOOST_CHECK_EQUAL(result.get<0>(), false);
-  BOOST_CHECK_EQUAL(result.get<1>(), false);
-  BOOST_CHECK_EQUAL(result.get<2>(), 0);
+  BOOST_CHECK_EQUAL(std::get<0>(result), false);
+  BOOST_CHECK_EQUAL(std::get<1>(result), false);
+  BOOST_CHECK_EQUAL(std::get<2>(result), 0);
 
   BOOST_CHECK_EQUAL(state.getLeaves().size(), 1);
   BOOST_CHECK_EQUAL((*state.getLeaves().begin())->getSeq(), 12);
@@ -67,9 +68,9 @@
   BOOST_CHECK_EQUAL((*state.getLeaves().begin())->getSeq(), 13);
 
   result = state.update(info, 14);
-  BOOST_CHECK_EQUAL(result.get<0>(), false);
-  BOOST_CHECK_EQUAL(result.get<1>(), true);
-  BOOST_CHECK_EQUAL(result.get<2>(), 13);
+  BOOST_CHECK_EQUAL(std::get<0>(result), false);
+  BOOST_CHECK_EQUAL(std::get<1>(result), true);
+  BOOST_CHECK_EQUAL(std::get<2>(result), 13);
 
   BOOST_CHECK_EQUAL(state.getLeaves().size(), 1);
   BOOST_CHECK_EQUAL((*state.getLeaves().begin())->getSeq(), 14);
diff --git a/tests/wscript b/tests/wscript
index bacd16b..3e98b34 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -15,7 +15,7 @@
 
     unit_test = bld.program(
         target="../unit-tests",
-        source=bld.path.ant_glob(['unit-tests/**/*.cpp']),
+        source=bld.path.ant_glob(['unit-tests/**/*.cpp', 'identity-management-fixture.cpp']),
         features=['cxx', 'cxxprogram'],
         use='ChronoSync tests-main',
         includes=['.'],
