Fix compilation with latest ndn-cxx

Change-Id: Iaf468a75466134d18ecbb1fef66e4cb401d781a4
diff --git a/common.hpp b/common.hpp
index ce1f776..fb6b44f 100644
--- a/common.hpp
+++ b/common.hpp
@@ -39,13 +39,20 @@
 
 #include <cstddef>
 #include <list>
-#include <set>
 #include <queue>
+#include <set>
 #include <vector>
+#include <tuple>
 
-#include <ndn-cxx/common.hpp>
-#include <ndn-cxx/interest.hpp>
 #include <ndn-cxx/data.hpp>
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/security/signing-helpers.hpp>
+#include <ndn-cxx/security/v2/validator.hpp>
+#include <ndn-cxx/security/validator-config.hpp>
+#include <ndn-cxx/util/scheduler.hpp>
+#include <ndn-cxx/util/time.hpp>
 
 #include <boost/algorithm/string.hpp>
 #include <boost/asio.hpp>
@@ -64,23 +71,27 @@
 using boost::noncopyable;
 using boost::scoped_ptr;
 
-using std::shared_ptr;
-using std::weak_ptr;
-using std::enable_shared_from_this;
-using std::make_shared;
-using std::static_pointer_cast;
-using std::dynamic_pointer_cast;
-using std::const_pointer_cast;
-using std::function;
 using std::bind;
-using std::ref;
+using std::const_pointer_cast;
 using std::cref;
+using std::dynamic_pointer_cast;
+using std::enable_shared_from_this;
+using std::function;
+using std::make_shared;
+using std::make_tuple;
+using std::ref;
+using std::shared_ptr;
+using std::static_pointer_cast;
+using std::weak_ptr;
 
-using ndn::Interest;
-using ndn::Data;
-using ndn::Name;
-using ndn::Exclude;
 using ndn::Block;
+using ndn::ConstBufferPtr;
+using ndn::Data;
+using ndn::Exclude;
+using ndn::Interest;
+using ndn::Name;
+using ndn::security::v2::ValidationError;
+using ndn::security::v2::Validator;
 
 namespace tlv {
 using namespace ndn::tlv;
@@ -89,6 +100,7 @@
 namespace name = ndn::name;
 namespace time = ndn::time;
 namespace security = ndn::security;
+namespace encoding = ndn::encoding;
 
 } // namespace chronosync
 
diff --git a/docs/doxygen.conf.in b/docs/doxygen.conf.in
index 92989c0..416e292 100644
--- a/docs/doxygen.conf.in
+++ b/docs/doxygen.conf.in
@@ -1917,7 +1917,9 @@
 # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
 
 PREDEFINED             = DOXYGEN=1 \
-                         CHRONOSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE=private
+                         CHRONOSYNC_PUBLIC_WITH_TESTS_ELSE_PRIVATE=private \
+                         NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS= \
+                         NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS=
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
 # tag can be used to specify a list of macro names that should be expanded. The
diff --git a/src/boost-header.h b/src/boost-header.h
deleted file mode 100644
index aca4ba8..0000000
--- a/src/boost-header.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2012-2014 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/>.
- *
- * @author Yingdi Yu <yingdi@cs.ucla.edu>
- */
-
-#ifndef BOOST_HEADER_HPP
-#define BOOST_HEADER_HPP
-
-// suppress Boost warnings
-#pragma GCC system_header
-#pragma clang system_header
-
-#include <boost/random.hpp>
-
-#include <boost/assert.hpp>
-#include <boost/throw_exception.hpp>
-
-#include <boost/iterator/transform_iterator.hpp>
-#include <boost/archive/iterators/dataflow_exception.hpp>
-#include <boost/archive/iterators/transform_width.hpp>
-
-#endif // BOOST_HEADER_HPP
diff --git a/src/diff-state-container.hpp b/src/diff-state-container.hpp
index d20fbee..f03caf1 100644
--- a/src/diff-state-container.hpp
+++ b/src/diff-state-container.hpp
@@ -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.
@@ -42,7 +42,7 @@
 struct DigestPtrHash
 {
   std::size_t
-  operator()(ndn::ConstBufferPtr digest) const
+  operator()(ConstBufferPtr digest) const
   {
     BOOST_ASSERT(digest->size() > sizeof(std::size_t));
 
@@ -53,7 +53,7 @@
 struct DigestPtrEqual
 {
   bool
-  operator()(ndn::ConstBufferPtr digest1, ndn::ConstBufferPtr digest2) const
+  operator()(ConstBufferPtr digest1, ConstBufferPtr digest2) const
   {
     return *digest1 == *digest2;
   }
@@ -68,7 +68,7 @@
     // For fast access to elements using DiffState hashes
     mi::hashed_unique<
       mi::tag<hashed>,
-      mi::const_mem_fun<DiffState, ndn::ConstBufferPtr, &DiffState::getRootDigest>,
+      mi::const_mem_fun<DiffState, ConstBufferPtr, &DiffState::getRootDigest>,
       DigestPtrHash,
       DigestPtrEqual
       >,
diff --git a/src/diff-state.hpp b/src/diff-state.hpp
index 46ed412..7a59e3a 100644
--- a/src/diff-state.hpp
+++ b/src/diff-state.hpp
@@ -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.
@@ -30,8 +30,8 @@
 namespace chronosync {
 
 class DiffState;
-typedef shared_ptr<DiffState> DiffStatePtr;
-typedef shared_ptr<const DiffState> ConstDiffStatePtr;
+using DiffStatePtr = shared_ptr<DiffState>;
+using ConstDiffStatePtr = shared_ptr<const DiffState>;
 
 /**
  * @brief Contains the diff info between two states.
@@ -67,7 +67,7 @@
    * @param digest root digest of the full state
    */
   void
-  setRootDigest(ndn::ConstBufferPtr digest)
+  setRootDigest(ConstBufferPtr digest)
   {
     m_digest = digest;
   }
@@ -75,7 +75,7 @@
   /**
    * @brief Get root digest of the full state after applying the diff state
    */
-  ndn::ConstBufferPtr
+  ConstBufferPtr
   getRootDigest() const
   {
     return m_digest;
@@ -95,10 +95,10 @@
   diff() const;
 
 private:
-  ConstDiffStatePtr   m_next;
-  ndn::ConstBufferPtr m_digest;
+  ConstDiffStatePtr m_next;
+  ConstBufferPtr m_digest;
 };
 
-} // chronosync
+} // namespace chronosync
 
 #endif // CHRONOSYNC_DIFF_STATE_HPP
diff --git a/src/interest-container.cpp b/src/interest-container.cpp
index 4d42321..3a5e5f4 100644
--- a/src/interest-container.cpp
+++ b/src/interest-container.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.
@@ -26,8 +26,8 @@
 
 namespace chronosync {
 
-UnsatisfiedInterest::UnsatisfiedInterest(shared_ptr<const Interest> interest,
-                                         ndn::ConstBufferPtr digest,
+UnsatisfiedInterest::UnsatisfiedInterest(const Interest& interest,
+                                         ConstBufferPtr digest,
                                          bool isUnknown)
   : interest(interest)
   , digest(digest)
diff --git a/src/interest-container.hpp b/src/interest-container.hpp
index bf971eb..de7043a 100644
--- a/src/interest-container.hpp
+++ b/src/interest-container.hpp
@@ -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.
@@ -29,9 +29,6 @@
 #include "mi-tag.hpp"
 #include "diff-state-container.hpp"
 
-#include <ndn-cxx/util/time.hpp>
-#include <ndn-cxx/util/scheduler.hpp>
-
 #include <boost/multi_index_container.hpp>
 #include <boost/multi_index/tag.hpp>
 #include <boost/multi_index/hashed_index.hpp>
@@ -46,19 +43,19 @@
 class UnsatisfiedInterest : noncopyable
 {
 public:
-  UnsatisfiedInterest(shared_ptr<const Interest> interest,
-                      ndn::ConstBufferPtr digest,
+  UnsatisfiedInterest(const Interest& interest,
+                      ConstBufferPtr digest,
                       bool isUnknown = false);
 
 public:
-  shared_ptr<const Interest> interest;
-  ndn::ConstBufferPtr        digest;
-  bool                       isUnknown;
-  ndn::EventId               expirationEvent;
+  const Interest interest;
+  ConstBufferPtr digest;
+  bool           isUnknown;
+  ndn::EventId   expirationEvent;
 };
 
-typedef shared_ptr<UnsatisfiedInterest> UnsatisfiedInterestPtr;
-typedef shared_ptr<const UnsatisfiedInterest> ConstUnsatisfiedInterestPtr;
+using UnsatisfiedInterestPtr = shared_ptr<UnsatisfiedInterest>;
+using ConstUnsatisfiedInterestPtr = shared_ptr<const UnsatisfiedInterest>;
 
 /**
  * @brief Container for unsatisfied Sync Interests
@@ -68,7 +65,7 @@
   mi::indexed_by<
     mi::hashed_unique<
       mi::tag<hashed>,
-      mi::member<UnsatisfiedInterest, ndn::ConstBufferPtr, &UnsatisfiedInterest::digest>,
+      mi::member<UnsatisfiedInterest, ConstBufferPtr, &UnsatisfiedInterest::digest>,
       DigestPtrHash,
       DigestPtrEqual
       >
diff --git a/src/interest-table.cpp b/src/interest-table.cpp
index efe7fef..2b3c9d6 100644
--- a/src/interest-table.cpp
+++ b/src/interest-table.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.
@@ -37,38 +37,35 @@
 }
 
 void
-InterestTable::insert(shared_ptr<const Interest> interest,
-                      ndn::ConstBufferPtr digest,
-                      bool isKnown/*=false*/)
+InterestTable::insert(const Interest& interest, ConstBufferPtr digest, bool isKnown/*=false*/)
 {
   erase(digest);
 
-  UnsatisfiedInterestPtr request =
-    make_shared<UnsatisfiedInterest>(interest, digest, isKnown);
+  auto request = make_shared<UnsatisfiedInterest>(interest, digest, isKnown);
 
-  time::milliseconds entryLifetime = interest->getInterestLifetime();
+  time::milliseconds entryLifetime = interest.getInterestLifetime();
   if (entryLifetime < time::milliseconds::zero())
     entryLifetime = ndn::DEFAULT_INTEREST_LIFETIME;
 
-  request->expirationEvent =
-    m_scheduler.scheduleEvent(entryLifetime,
-                              [=] () { erase(digest); });
+  request->expirationEvent = m_scheduler.scheduleEvent(entryLifetime, [=] { erase(digest); });
 
   m_table.insert(request);
 }
 
 void
-InterestTable::erase(ndn::ConstBufferPtr digest)
+InterestTable::erase(ConstBufferPtr digest)
 {
-  InterestContainer::index<hashed>::type::iterator it = m_table.get<hashed>().find(digest);
-  if (it != m_table.get<hashed>().end()) {
+  auto it = m_table.get<hashed>().find(digest);
+  while (it != m_table.get<hashed>().end()) {
     m_scheduler.cancelEvent((*it)->expirationEvent);
     m_table.erase(it);
+
+    it = m_table.get<hashed>().find(digest);
   }
 }
 
 bool
-InterestTable::has(ndn::ConstBufferPtr digest)
+InterestTable::has(ConstBufferPtr digest)
 {
   if (m_table.get<hashed>().find(digest) != m_table.get<hashed>().end())
     return true;
@@ -85,12 +82,11 @@
 void
 InterestTable::clear()
 {
-  for (InterestContainer::iterator it = m_table.begin();
-       it != m_table.end(); it++) {
-    m_scheduler.cancelEvent((*it)->expirationEvent);
+  for (const auto& item : m_table) {
+    m_scheduler.cancelEvent(item->expirationEvent);
   }
 
   m_table.clear();
 }
 
-}
+} // namespace chronosync
diff --git a/src/interest-table.hpp b/src/interest-table.hpp
index 5292a69..bf5685b 100644
--- a/src/interest-table.hpp
+++ b/src/interest-table.hpp
@@ -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.
@@ -27,8 +27,6 @@
 
 #include "interest-container.hpp"
 
-#include <ndn-cxx/util/scheduler.hpp>
-
 namespace chronosync {
 
 /**
@@ -47,8 +45,8 @@
     }
   };
 
-  typedef InterestContainer::iterator iterator;
-  typedef InterestContainer::const_iterator const_iterator;
+  using iterator = InterestContainer::iterator;
+  using const_iterator = InterestContainer::const_iterator;
 
   explicit
   InterestTable(boost::asio::io_service& io);
@@ -69,17 +67,15 @@
    * @param isKnown  false if the digest is an unknown digest.
    */
   void
-  insert(shared_ptr<const Interest> interest,
-         ndn::ConstBufferPtr digest,
-         bool isKnown = false);
+  insert(const Interest& interest, ConstBufferPtr digest, bool isKnown = false);
 
   /// @brief check if an interest with the digest exists in the table
   bool
-  has(ndn::ConstBufferPtr digest);
+  has(ConstBufferPtr digest);
 
   /// @brief Delete interest by digest (e.g., when it was satisfied)
   void
-  erase(ndn::ConstBufferPtr digest);
+  erase(ConstBufferPtr digest);
 
   const_iterator
   begin() const
@@ -113,9 +109,6 @@
 
 private:
   ndn::Scheduler m_scheduler;
-  ndn::time::steady_clock::Duration m_entryLifetime;
-  ndn::time::steady_clock::Duration m_cleanPeriod;
-
   InterestContainer m_table;
 };
 
diff --git a/src/leaf-container.hpp b/src/leaf-container.hpp
index e1d30bd..f08f8f9 100644
--- a/src/leaf-container.hpp
+++ b/src/leaf-container.hpp
@@ -44,7 +44,7 @@
   std::size_t
   operator()(const Name& prefix) const
   {
-    ndn::ConstBufferPtr buffer =
+    ConstBufferPtr buffer =
       ndn::util::Sha256::computeDigest(prefix.wireEncode().wire(), prefix.wireEncode().size());
 
     BOOST_ASSERT(buffer->size() > sizeof(std::size_t));
diff --git a/src/leaf.cpp b/src/leaf.cpp
index 129b1ea..2bf6325 100644
--- a/src/leaf.cpp
+++ b/src/leaf.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.
@@ -44,7 +44,7 @@
 {
 }
 
-ndn::ConstBufferPtr
+ConstBufferPtr
 Leaf::getDigest() const
 {
   return m_digest.computeDigest();
diff --git a/src/leaf.hpp b/src/leaf.hpp
index 4c8223d..63284b8 100644
--- a/src/leaf.hpp
+++ b/src/leaf.hpp
@@ -26,11 +26,12 @@
 #define CHRONOSYNC_LEAF_HPP
 
 #include "common.hpp"
+
 #include <ndn-cxx/util/sha256.hpp>
 
 namespace chronosync {
 
-typedef uint64_t SeqNo;
+using SeqNo = uint64_t;
 
 /**
  * @brief Sync tree leaf
@@ -59,7 +60,7 @@
     return m_seq;
   }
 
-  ndn::ConstBufferPtr
+  ConstBufferPtr
   getDigest() const;
 
   /**
@@ -82,8 +83,8 @@
   mutable ndn::util::Sha256 m_digest;
 };
 
-typedef shared_ptr<Leaf> LeafPtr;
-typedef shared_ptr<const Leaf> ConstLeafPtr;
+using LeafPtr = shared_ptr<Leaf>;
+using ConstLeafPtr = shared_ptr<const Leaf>;
 
 std::ostream&
 operator<<(std::ostream& os, const Leaf& leaf);
diff --git a/src/logic.cpp b/src/logic.cpp
index d3e5f11..44115eb 100644
--- a/src/logic.cpp
+++ b/src/logic.cpp
@@ -38,7 +38,6 @@
 
 namespace chronosync {
 
-using ndn::ConstBufferPtr;
 using ndn::EventId;
 
 const uint8_t EMPTY_DIGEST_VALUE[] = {
@@ -49,12 +48,12 @@
 };
 
 #ifdef _DEBUG
-int Logic::m_instanceCounter = 0;
+int Logic::s_instanceCounter = 0;
 #endif
 
 const ndn::Name Logic::DEFAULT_NAME;
 const ndn::Name Logic::EMPTY_NAME;
-const std::shared_ptr<ndn::Validator> Logic::DEFAULT_VALIDATOR;
+const std::shared_ptr<Validator> Logic::DEFAULT_VALIDATOR;
 const time::steady_clock::Duration Logic::DEFAULT_RESET_TIMER = time::seconds(0);
 const time::steady_clock::Duration Logic::DEFAULT_CANCEL_RESET_TIMER = time::milliseconds(500);
 const time::milliseconds Logic::DEFAULT_RESET_INTEREST_LIFETIME(1000);
@@ -62,7 +61,7 @@
 const time::milliseconds Logic::DEFAULT_SYNC_REPLY_FRESHNESS(1000);
 const time::milliseconds Logic::DEFAULT_RECOVERY_INTEREST_LIFETIME(1000);
 
-const ndn::ConstBufferPtr Logic::EMPTY_DIGEST(new ndn::Buffer(EMPTY_DIGEST_VALUE, 32));
+const ConstBufferPtr Logic::EMPTY_DIGEST(new ndn::Buffer(EMPTY_DIGEST_VALUE, 32));
 const ndn::name::Component Logic::RESET_COMPONENT("reset");
 const ndn::name::Component Logic::RECOVERY_COMPONENT("recovery");
 
@@ -71,7 +70,7 @@
              const Name& defaultUserPrefix,
              const UpdateCallback& onUpdate,
              const Name& defaultSigningId,
-             std::shared_ptr<ndn::Validator> validator,
+             std::shared_ptr<Validator> validator,
              const time::steady_clock::Duration& resetTimer,
              const time::steady_clock::Duration& cancelResetTimer,
              const time::milliseconds& resetInterestLifetime,
@@ -99,7 +98,7 @@
   , m_validator(validator)
 {
 #ifdef _DEBUG
-  m_instanceId = m_instanceCounter++;
+  m_instanceId = s_instanceCounter++;
 #endif
 
   _LOG_DEBUG_ID(">> Logic::Logic");
@@ -251,7 +250,7 @@
 
     if (!m_isInReset) {
       _LOG_DEBUG_ID("updateSeqNo: not in Reset ");
-      ndn::ConstBufferPtr previousRoot = m_state.getRootDigest();
+      ConstBufferPtr previousRoot = m_state.getRootDigest();
       {
         std::string hash = ndn::toHex(previousRoot->buf(), previousRoot->size(), false);
         _LOG_DEBUG_ID("Hash: " << hash);
@@ -260,8 +259,7 @@
       bool isInserted = false;
       bool isUpdated = false;
       SeqNo oldSeq;
-      boost::tie(isInserted, isUpdated, oldSeq) = m_state.update(node.sessionName,
-                                                                 node.seqNo);
+      std::tie(isInserted, isUpdated, oldSeq) = m_state.update(node.sessionName, node.seqNo);
 
       _LOG_DEBUG_ID("Insert: " << std::boolalpha << isInserted);
       _LOG_DEBUG_ID("Updated: " << std::boolalpha << isUpdated);
@@ -322,7 +320,7 @@
   }
   // Do not process exclude interests, they should be answered by CS
   else if (interest.getExclude().empty()) {
-    processSyncInterest(interest.shared_from_this());
+    processSyncInterest(interest);
   }
 
   _LOG_DEBUG_ID("<< Logic::onSyncInterest");
@@ -344,15 +342,15 @@
   //                         bind(&Logic::onSyncDataValidated, this, _1),
   //                         bind(&Logic::onSyncDataValidationFailed, this, _1));
   // else
-  //   onSyncDataValidated(data.shared_from_this());
+  //   onSyncDataValidated(data);
 
   if (interest.getExclude().empty()) {
     _LOG_DEBUG_ID("First data");
-    onSyncDataValidated(data.shared_from_this());
+    onSyncDataValidated(data);
   }
   else {
     _LOG_DEBUG_ID("Data obtained using exclude filter");
-    onSyncDataValidated(data.shared_from_this(), false);
+    onSyncDataValidated(data, false);
   }
   sendExcludeInterest(interest, data);
 
@@ -375,29 +373,27 @@
 }
 
 void
-Logic::onSyncDataValidationFailed(const shared_ptr<const Data>& data)
+Logic::onSyncDataValidationFailed(const Data& data)
 {
   // SyncReply cannot be validated.
 }
 
 void
-Logic::onSyncDataValidated(const shared_ptr<const Data>& data, bool firstData)
+Logic::onSyncDataValidated(const Data& data, bool firstData)
 {
-  Name name = data->getName();
+  Name name = data.getName();
   ConstBufferPtr digest = make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
 
-  processSyncData(name, digest, data->getContent().blockFromValue(), firstData);
+  processSyncData(name, digest, data.getContent().blockFromValue(), firstData);
 }
 
 void
-Logic::processSyncInterest(const shared_ptr<const Interest>& interest,
-                           bool isTimedProcessing/*=false*/)
+Logic::processSyncInterest(const Interest& interest, bool isTimedProcessing/*=false*/)
 {
   _LOG_DEBUG_ID(">> Logic::processSyncInterest");
 
-  const Name& name = interest->getName();
-  ConstBufferPtr digest =
-      make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
+  Name name = interest.getName();
+  ConstBufferPtr digest = make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
 
   ConstBufferPtr rootDigest = m_state.getRootDigest();
 
@@ -480,13 +476,13 @@
 
 void
 Logic::processSyncData(const Name& name,
-                       ndn::ConstBufferPtr digest,
+                       ConstBufferPtr digest,
                        const Block& syncReplyBlock,
                        bool firstData)
 {
   _LOG_DEBUG_ID(">> Logic::processSyncData");
   DiffStatePtr commit = make_shared<DiffState>();
-  ndn::ConstBufferPtr previousRoot = m_state.getRootDigest();
+  ConstBufferPtr previousRoot = m_state.getRootDigest();
 
   try {
     m_interestTable.erase(digest); // Remove satisfied interest from PIT
@@ -505,7 +501,7 @@
         bool isInserted = false;
         bool isUpdated = false;
         SeqNo oldSeq;
-        boost::tie(isInserted, isUpdated, oldSeq) = m_state.update(info, seq);
+        std::tie(isInserted, isUpdated, oldSeq) = m_state.update(info, seq);
         if (isInserted || isUpdated) {
           commit->update(info, seq);
 
@@ -550,13 +546,14 @@
   _LOG_DEBUG_ID(">> Logic::satisfyPendingSyncInterests");
   try {
     _LOG_DEBUG_ID("InterestTable size: " << m_interestTable.size());
-    for (InterestTable::const_iterator it = m_interestTable.begin();
-         it != m_interestTable.end(); it++) {
+    auto it = m_interestTable.begin();
+    while (it != m_interestTable.end()) {
       ConstUnsatisfiedInterestPtr request = *it;
+      ++it;
       if (request->isUnknown)
-        sendSyncData(updatedPrefix, request->interest->getName(), m_state);
+        sendSyncData(updatedPrefix, request->interest.getName(), m_state);
       else
-        sendSyncData(updatedPrefix, request->interest->getName(), *commit);
+        sendSyncData(updatedPrefix, request->interest.getName(), *commit);
     }
     m_interestTable.clear();
   }
@@ -567,7 +564,7 @@
 }
 
 void
-Logic::insertToDiffLog(DiffStatePtr commit, ndn::ConstBufferPtr previousRoot)
+Logic::insertToDiffLog(DiffStatePtr commit, ConstBufferPtr previousRoot)
 {
   _LOG_DEBUG_ID(">> Logic::insertToDiffLog");
   // Connect to the history
@@ -646,17 +643,17 @@
 Logic::sendSyncData(const Name& nodePrefix, const Name& name, const State& state)
 {
   _LOG_DEBUG_ID(">> Logic::sendSyncData");
-  shared_ptr<Data> syncReply = make_shared<Data>(name);
-  syncReply->setContent(state.wireEncode());
-  syncReply->setFreshnessPeriod(m_syncReplyFreshness);
+  Data syncReply(name);
+  syncReply.setContent(state.wireEncode());
+  syncReply.setFreshnessPeriod(m_syncReplyFreshness);
   if (m_nodeList.find(nodePrefix) == m_nodeList.end())
     return;
   if (m_nodeList[nodePrefix].signingId.empty())
-    m_keyChain.sign(*syncReply);
+    m_keyChain.sign(syncReply);
   else
-    m_keyChain.sign(*syncReply, security::signingByIdentity(m_nodeList[nodePrefix].signingId));
+    m_keyChain.sign(syncReply, security::signingByIdentity(m_nodeList[nodePrefix].signingId));
 
-  m_face.put(*syncReply);
+  m_face.put(syncReply);
 
   // checking if our own interest got satisfied
   if (m_outstandingInterestName == name) {
@@ -692,14 +689,14 @@
 }
 
 void
-Logic::printDigest(ndn::ConstBufferPtr digest)
+Logic::printDigest(ConstBufferPtr digest)
 {
   std::string hash = ndn::toHex(digest->buf(), digest->size(), false);
   _LOG_DEBUG_ID("Hash: " << hash);
 }
 
 void
-Logic::sendRecoveryInterest(ndn::ConstBufferPtr digest)
+Logic::sendRecoveryInterest(ConstBufferPtr digest)
 {
   _LOG_DEBUG_ID(">> Logic::sendRecoveryInterest");
 
@@ -726,7 +723,7 @@
 {
   _LOG_DEBUG_ID(">> Logic::processRecoveryInterest");
 
-  const Name& name = interest.getName();
+  Name name = interest.getName();
   ConstBufferPtr digest = make_shared<ndn::Buffer>(name.get(-1).value(), name.get(-1).value_size());
 
   ConstBufferPtr rootDigest = m_state.getRootDigest();
@@ -745,7 +742,7 @@
 Logic::onRecoveryData(const Interest& interest, const Data& data)
 {
   _LOG_DEBUG_ID(">> Logic::onRecoveryData");
-  onSyncDataValidated(data.shared_from_this());
+  onSyncDataValidated(data);
   _LOG_DEBUG_ID("<< Logic::onRecoveryData");
 }
 
@@ -785,7 +782,7 @@
 }
 
 void
-Logic::formAndSendExcludeInterest(const Name& nodePrefix, const State& commit, ndn::ConstBufferPtr previousRoot)
+Logic::formAndSendExcludeInterest(const Name& nodePrefix, const State& commit, ConstBufferPtr previousRoot)
 {
   _LOG_DEBUG_ID(">> Logic::formAndSendExcludeInterest");
   Name interestName;
@@ -793,17 +790,17 @@
               .append(ndn::name::Component(*previousRoot));
   Interest interest(interestName);
 
-  shared_ptr<Data> data = make_shared<Data>(interestName);
-  data->setContent(commit.wireEncode());
-  data->setFreshnessPeriod(m_syncReplyFreshness);
+  Data data(interestName);
+  data.setContent(commit.wireEncode());
+  data.setFreshnessPeriod(m_syncReplyFreshness);
   if (m_nodeList.find(nodePrefix) == m_nodeList.end())
     return;
   if (m_nodeList[nodePrefix].signingId.empty())
-    m_keyChain.sign(*data);
+    m_keyChain.sign(data);
   else
-    m_keyChain.sign(*data, security::signingByIdentity(m_nodeList[nodePrefix].signingId));
+    m_keyChain.sign(data, security::signingByIdentity(m_nodeList[nodePrefix].signingId));
 
-  sendExcludeInterest(interest, *data);
+  sendExcludeInterest(interest, data);
 
   _LOG_DEBUG_ID("<< Logic::formAndSendExcludeInterest");
 }
diff --git a/src/logic.hpp b/src/logic.hpp
index 78080ae..453a843 100644
--- a/src/logic.hpp
+++ b/src/logic.hpp
@@ -26,19 +26,19 @@
 #ifndef CHRONOSYNC_LOGIC_HPP
 #define CHRONOSYNC_LOGIC_HPP
 
-#include "boost-header.h"
 #include "diff-state-container.hpp"
 #include "interest-table.hpp"
 
+#include <boost/archive/iterators/dataflow_exception.hpp>
+#include <boost/archive/iterators/transform_width.hpp>
+#include <boost/assert.hpp>
+#include <boost/iterator/transform_iterator.hpp>
+#include <boost/random.hpp>
+#include <boost/throw_exception.hpp>
+
 #include <memory>
 #include <unordered_map>
 
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/util/scheduler.hpp>
-#include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/security/signing-helpers.hpp>
-#include <ndn-cxx/security/validator.hpp>
-
 namespace chronosync {
 
 /**
@@ -76,7 +76,7 @@
  * The parameter is a set of MissingDataInfo, of which each corresponds to
  * a session that has changed its state.
  */
-typedef function<void(const std::vector<MissingDataInfo>&)> UpdateCallback;
+using UpdateCallback = function<void(const std::vector<MissingDataInfo>&)>;
 
 /**
  * @brief Logic of ChronoSync
@@ -123,7 +123,7 @@
         const Name& defaultUserPrefix,
         const UpdateCallback& onUpdate,
         const Name& defaultSigningId = DEFAULT_NAME,
-        std::shared_ptr<ndn::Validator> validator = DEFAULT_VALIDATOR,
+        std::shared_ptr<Validator> validator = DEFAULT_VALIDATOR,
         const time::steady_clock::Duration& resetTimer = DEFAULT_RESET_TIMER,
         const time::steady_clock::Duration& cancelResetTimer = DEFAULT_CANCEL_RESET_TIMER,
         const time::milliseconds& resetInterestLifetime = DEFAULT_RESET_INTEREST_LIFETIME,
@@ -207,7 +207,7 @@
   updateSeqNo(const SeqNo& seq, const Name& updatePrefix = EMPTY_NAME);
 
   /// @brief Get root digest of current sync tree
-  ndn::ConstBufferPtr
+  ConstBufferPtr
   getRootDigest() const;
 
   /// @brief Get the name of all sessions
@@ -297,7 +297,7 @@
    * @param data The invalid Sync Reply
    */
   void
-  onSyncDataValidationFailed(const shared_ptr<const Data>& data);
+  onSyncDataValidationFailed(const Data& data);
 
   /**
    * @brief Callback to valid Sync Reply.
@@ -308,7 +308,7 @@
    * @param firstData Whether the data is new or that obtained using exclude filter
    */
   void
-  onSyncDataValidated(const shared_ptr<const Data>& data, bool firstData = true);
+  onSyncDataValidated(const Data& data, bool firstData = true);
 
   /**
    * @brief Process normal Sync Interest
@@ -324,8 +324,7 @@
    *                          making a reply (to avoid unnecessary recovery)
    */
   void
-  processSyncInterest(const shared_ptr<const Interest>& interest,
-                      bool isTimedProcessing = false);
+  processSyncInterest(const Interest& interest, bool isTimedProcessing = false);
 
   /**
    * @brief Process reset Sync Interest
@@ -350,7 +349,7 @@
    */
   void
   processSyncData(const Name& name,
-                  ndn::ConstBufferPtr digest,
+                  ConstBufferPtr digest,
                   const Block& syncReplyBlock,
                   bool firstData);
 
@@ -362,7 +361,7 @@
    */
   void
   insertToDiffLog(DiffStatePtr diff,
-                  ndn::ConstBufferPtr previousRoot);
+                  ConstBufferPtr previousRoot);
 
   /**
    * @brief Reply to all pending Sync Interests with a particular commit (or diff)
@@ -394,7 +393,7 @@
   cancelReset();
 
   void
-  printDigest(ndn::ConstBufferPtr digest);
+  printDigest(ConstBufferPtr digest);
 
   /**
    * @brief Helper method to send Recovery Interest
@@ -402,7 +401,7 @@
    * @param digest    The digest to be included in the recovery interest
    */
   void
-  sendRecoveryInterest(ndn::ConstBufferPtr digest);
+  sendRecoveryInterest(ConstBufferPtr digest);
 
   /**
    * @brief Process Recovery Interest
@@ -458,17 +457,17 @@
   void
   formAndSendExcludeInterest(const Name& nodePrefix,
                              const State& commit,
-                             ndn::ConstBufferPtr previousRoot);
+                             ConstBufferPtr previousRoot);
 
 public:
   static const ndn::Name DEFAULT_NAME;
   static const ndn::Name EMPTY_NAME;
-  static const std::shared_ptr<ndn::Validator> DEFAULT_VALIDATOR;
+  static const std::shared_ptr<Validator> DEFAULT_VALIDATOR;
 
 private:
-  typedef std::unordered_map<ndn::Name, NodeInfo> NodeList;
+  using NodeList = std::unordered_map<ndn::Name, NodeInfo>;
 
-  static const ndn::ConstBufferPtr EMPTY_DIGEST;
+  static const ConstBufferPtr EMPTY_DIGEST;
   static const ndn::name::Component RESET_COMPONENT;
   static const ndn::name::Component RECOVERY_COMPONENT;
 
@@ -517,12 +516,12 @@
 
   // Security
   ndn::KeyChain m_keyChain;
-  std::shared_ptr<ndn::Validator> m_validator;
+  std::shared_ptr<Validator> m_validator;
 
 
 #ifdef _DEBUG
   int m_instanceId;
-  static int m_instanceCounter;
+  static int s_instanceCounter;
 #endif
 };
 
diff --git a/src/socket.cpp b/src/socket.cpp
index f70d900..d3184d2 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -27,19 +27,18 @@
 
 INIT_LOGGER(Socket);
 
-
 namespace chronosync {
 
 const ndn::Name Socket::DEFAULT_NAME;
 const ndn::Name Socket::DEFAULT_PREFIX;
-const std::shared_ptr<ndn::Validator> Socket::DEFAULT_VALIDATOR;
+const std::shared_ptr<Validator> Socket::DEFAULT_VALIDATOR;
 
 Socket::Socket(const Name& syncPrefix,
                const Name& userPrefix,
                ndn::Face& face,
                const UpdateCallback& updateCallback,
                const Name& signingId,
-               std::shared_ptr<ndn::Validator> validator)
+               std::shared_ptr<Validator> validator)
   : m_userPrefix(userPrefix)
   , m_face(face)
   , m_logic(face, syncPrefix, userPrefix, updateCallback)
@@ -161,7 +160,7 @@
 
 void
 Socket::fetchData(const Name& sessionName, const SeqNo& seqNo,
-                  const ndn::OnDataValidated& dataCallback,
+                  const DataValidatedCallback& dataCallback,
                   int nRetries)
 {
   Name interestName;
@@ -170,7 +169,7 @@
   Interest interest(interestName);
   interest.setMustBeFresh(true);
 
-  ndn::OnDataValidationFailed failureCallback =
+  DataValidationErrorCallback failureCallback =
     bind(&Socket::onDataValidationFailed, this, _1, _2);
 
   m_face.expressInterest(interest,
@@ -183,8 +182,8 @@
 
 void
 Socket::fetchData(const Name& sessionName, const SeqNo& seqNo,
-                  const ndn::OnDataValidated& dataCallback,
-                  const ndn::OnDataValidationFailed& failureCallback,
+                  const DataValidatedCallback& dataCallback,
+                  const DataValidationErrorCallback& failureCallback,
                   const ndn::TimeoutCallback& onTimeout,
                   int nRetries)
 {
@@ -214,21 +213,21 @@
 
 void
 Socket::onData(const Interest& interest, const Data& data,
-               const ndn::OnDataValidated& onValidated,
-               const ndn::OnDataValidationFailed& onFailed)
+               const DataValidatedCallback& onValidated,
+               const DataValidationErrorCallback& onFailed)
 {
   _LOG_DEBUG("Socket::onData");
 
   if (static_cast<bool>(m_validator))
     m_validator->validate(data, onValidated, onFailed);
   else
-    onValidated(data.shared_from_this());
+    onValidated(data);
 }
 
 void
 Socket::onDataTimeout(const Interest& interest, int nRetries,
-                      const ndn::OnDataValidated& onValidated,
-                      const ndn::OnDataValidationFailed& onFailed)
+                      const DataValidatedCallback& onValidated,
+                      const DataValidationErrorCallback& onFailed)
 {
   _LOG_DEBUG("Socket::onDataTimeout");
   if (nRetries <= 0)
@@ -246,12 +245,12 @@
 }
 
 void
-Socket::onDataValidationFailed(const shared_ptr<const Data>& data,
-                               const std::string& failureInfo)
+Socket::onDataValidationFailed(const Data& data,
+                               const ValidationError& error)
 {
 }
 
-ndn::ConstBufferPtr
+ConstBufferPtr
 Socket::getRootDigest() const
 {
   return m_logic.getRootDigest();
diff --git a/src/socket.hpp b/src/socket.hpp
index 6ec0aef..94ba109 100644
--- a/src/socket.hpp
+++ b/src/socket.hpp
@@ -27,10 +27,10 @@
 
 #include "logic.hpp"
 
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/ims/in-memory-storage-persistent.hpp>
 #include <unordered_map>
 
+#include <ndn-cxx/ims/in-memory-storage-persistent.hpp>
+
 namespace chronosync {
 
 /**
@@ -64,10 +64,14 @@
          ndn::Face& face,
          const UpdateCallback& updateCallback,
          const Name& signingId = DEFAULT_NAME,
-         std::shared_ptr<ndn::Validator> validator = DEFAULT_VALIDATOR);
+         std::shared_ptr<Validator> validator = DEFAULT_VALIDATOR);
 
   ~Socket();
 
+  using DataValidatedCallback = function<void(const Data&)>;
+
+  using DataValidationErrorCallback = function<void(const Data&, const ValidationError& error)> ;
+
   /**
    * @brief Add a sync node under same logic
    *
@@ -175,7 +179,7 @@
    */
   void
   fetchData(const Name& sessionName, const SeqNo& seq,
-            const ndn::OnDataValidated& onValidated,
+            const DataValidatedCallback& onValidated,
             int nRetries = 0);
 
   /**
@@ -190,13 +194,13 @@
    */
   void
   fetchData(const Name& sessionName, const SeqNo& seq,
-            const ndn::OnDataValidated& onValidated,
-            const ndn::OnDataValidationFailed& onValidationFailed,
+            const DataValidatedCallback& onValidated,
+            const DataValidationErrorCallback& onValidationFailed,
             const ndn::TimeoutCallback& onTimeout,
             int nRetries = 0);
 
   /// @brief Get the root digest of current sync tree
-  ndn::ConstBufferPtr
+  ConstBufferPtr
   getRootDigest() const;
 
   Logic&
@@ -211,25 +215,25 @@
 
   void
   onData(const Interest& interest, const Data& data,
-         const ndn::OnDataValidated& dataCallback,
-         const ndn::OnDataValidationFailed& failCallback);
+         const DataValidatedCallback& dataCallback,
+         const DataValidationErrorCallback& failCallback);
 
   void
   onDataTimeout(const Interest& interest, int nRetries,
-                const ndn::OnDataValidated& dataCallback,
-                const ndn::OnDataValidationFailed& failCallback);
+                const DataValidatedCallback& dataCallback,
+                const DataValidationErrorCallback& failCallback);
 
   void
-  onDataValidationFailed(const shared_ptr<const Data>& data,
-                         const std::string& failureInfo);
+  onDataValidationFailed(const Data& data,
+                         const ValidationError& error);
 
 public:
   static const ndn::Name DEFAULT_NAME;
   static const ndn::Name DEFAULT_PREFIX;
-  static const std::shared_ptr<ndn::Validator> DEFAULT_VALIDATOR;
+  static const std::shared_ptr<Validator> DEFAULT_VALIDATOR;
 
 private:
-  typedef std::unordered_map<ndn::Name, const ndn::RegisteredPrefixId*> RegisteredPrefixList;
+  using RegisteredPrefixList = std::unordered_map<ndn::Name, const ndn::RegisteredPrefixId*>;
 
   Name m_userPrefix;
   ndn::Face& m_face;
@@ -237,7 +241,7 @@
 
   Name m_signingId;
   ndn::KeyChain m_keyChain;
-  std::shared_ptr<ndn::Validator> m_validator;
+  std::shared_ptr<Validator> m_validator;
 
   RegisteredPrefixList m_registeredPrefixList;
   ndn::InMemoryStoragePersistent m_ims;
diff --git a/src/state.cpp b/src/state.cpp
index 26a8944..b89509b 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -26,8 +26,6 @@
 
 namespace chronosync {
 
-using boost::make_tuple;
-
 State::~State()
 {
 }
@@ -39,7 +37,7 @@
  * @param seq  sequence number of the leaf
  * @return 3-tuple (isInserted, isUpdated, oldSeqNo)
  */
-boost::tuple<bool, bool, SeqNo>
+std::tuple<bool, bool, SeqNo>
 State::update(const Name& info, const SeqNo& seq)
 {
   m_wire.reset();
@@ -62,7 +60,7 @@
   }
 }
 
-ndn::ConstBufferPtr
+ConstBufferPtr
 State::getRootDigest() const
 {
   m_digest.reset();
@@ -95,9 +93,9 @@
   return *this;
 }
 
-template<bool T>
+template<encoding::Tag T>
 size_t
-State::wireEncode(ndn::EncodingImpl<T>& block) const
+State::wireEncode(encoding::EncodingImpl<T>& block) const
 {
   size_t totalLength = 0;
 
@@ -117,13 +115,7 @@
   return totalLength;
 }
 
-//! \relates State
-template size_t
-State::wireEncode<true>(ndn::EncodingImpl<true>& block) const;
-
-//! \relates State
-template size_t
-State::wireEncode<false>(ndn::EncodingImpl<false>& block) const;
+NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(State);
 
 const Block&
 State::wireEncode() const
diff --git a/src/state.hpp b/src/state.hpp
index 8713552..e5d0de2 100644
--- a/src/state.hpp
+++ b/src/state.hpp
@@ -25,15 +25,16 @@
 #ifndef CHRONOSYNC_STATE_HPP
 #define CHRONOSYNC_STATE_HPP
 
-#include "tlv.hpp"
 #include "leaf-container.hpp"
+#include "tlv.hpp"
+
 #include <ndn-cxx/util/sha256.hpp>
 
 namespace chronosync {
 
 class State;
-typedef shared_ptr<State> StatePtr;
-typedef shared_ptr<const State> ConstStatePtr;
+using StatePtr = shared_ptr<State>;
+using ConstStatePtr = shared_ptr<const State>;
 
 /**
  * @brief Abstraction of state tree.
@@ -65,7 +66,7 @@
    * @param seq  sequence number of the leaf
    * @return 3-tuple (isInserted, isUpdated, oldSeqNo)
    */
-  boost::tuple<bool, bool, SeqNo>
+  std::tuple<bool, bool, SeqNo>
   update(const Name& info, const SeqNo& seq);
 
   /**
@@ -77,7 +78,7 @@
     return m_leaves;
   }
 
-  ndn::ConstBufferPtr
+  ConstBufferPtr
   getRootDigest() const;
 
   /**
@@ -111,9 +112,9 @@
   wireDecode(const Block& wire);
 
 protected:
-  template<bool T>
+  template<encoding::Tag T>
   size_t
-  wireEncode(ndn::EncodingImpl<T>& block) const;
+  wireEncode(encoding::EncodingImpl<T>& block) const;
 
 protected:
   LeafContainer m_leaves;
@@ -122,6 +123,8 @@
   mutable Block m_wire;
 };
 
+NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(State);
+
 } // namespace chronosync
 
 #endif // CHRONOSYNC_STATE_HPP
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=['.'],