diff --git a/tests/dummy-face.hpp b/tests/dummy-face.hpp
new file mode 100644
index 0000000..a3a9402
--- /dev/null
+++ b/tests/dummy-face.hpp
@@ -0,0 +1,116 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014  University of Memphis,
+ *                     Regents of the University of California
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR 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.
+ *
+ * NLSR 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
+ * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ **/
+
+#ifndef NLSR_TEST_DUMMY_FACE_HPP
+#define NLSR_TEST_DUMMY_FACE_HPP
+
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/transport/transport.hpp>
+
+namespace ndn {
+
+class DummyTransport : public Transport
+{
+public:
+  void
+  receive(const Block& block)
+  {
+    m_receiveCallback(block);
+  }
+
+  virtual void
+  close()
+  {
+  }
+
+  virtual void
+  pause()
+  {
+  }
+
+  virtual void
+  resume()
+  {
+  }
+
+  virtual void
+  send(const Block& wire)
+  {
+    if (wire.type() == Tlv::Interest) {
+      m_sentInterests->push_back(Interest(wire));
+    }
+    else if (wire.type() == Tlv::Data) {
+      m_sentDatas->push_back(Data(wire));
+    }
+  }
+
+  virtual void
+  send(const Block& header, const Block& payload)
+  {
+    this->send(payload);
+  }
+
+public:
+  std::vector<Interest>* m_sentInterests;
+  std::vector<Data>*     m_sentDatas;
+};
+
+
+/** \brief a Face for unit testing
+ */
+class DummyFace : public Face
+{
+public:
+  explicit
+  DummyFace(shared_ptr<DummyTransport> transport)
+    : Face(transport)
+    , m_transport(transport)
+  {
+    m_transport->m_sentInterests = &m_sentInterests;
+    m_transport->m_sentDatas     = &m_sentDatas;
+  }
+
+  /** \brief cause the Face to receive a packet
+   */
+  template<typename Packet>
+  void
+  receive(const Packet& packet)
+  {
+    m_transport->receive(packet.wireEncode());
+  }
+
+public:
+  std::vector<Interest> m_sentInterests;
+  std::vector<Data>     m_sentDatas;
+
+private:
+  shared_ptr<DummyTransport> m_transport;
+};
+
+inline shared_ptr<DummyFace>
+makeDummyFace()
+{
+  return make_shared<DummyFace>(make_shared<DummyTransport>());
+}
+
+} // namespace ndn
+
+#endif // NLSR_TEST_DUMMY_FACE_HPP
\ No newline at end of file
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
index cbb83d9..dc60c90 100644
--- a/tests/test-common.hpp
+++ b/tests/test-common.hpp
@@ -24,6 +24,7 @@
 #define NLSR_TEST_COMMON_HPP
 
 #include <boost/asio.hpp>
+#include <boost/test/unit_test.hpp>
 #include <ndn-cxx/util/scheduler.hpp>
 
 namespace nlsr {
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index 44987de..d05e39c 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -22,6 +22,7 @@
  **/
 
 #include "test-common.hpp"
+#include "dummy-face.hpp"
 
 #include <fstream>
 #include "conf-file-processor.hpp"
@@ -31,11 +32,16 @@
 namespace nlsr {
 namespace test {
 
+using ndn::DummyFace;
+using ndn::shared_ptr;
+
 BOOST_FIXTURE_TEST_SUITE(TestConfFileProcessor, BaseFixture)
 
 BOOST_AUTO_TEST_CASE(ConfFileProcessorSample)
 {
-  Nlsr nlsr1(g_ioService, g_scheduler);
+  shared_ptr<DummyFace> face = ndn::makeDummyFace();
+
+  Nlsr nlsr1(g_ioService, g_scheduler, ndn::ref(*face));
 
   const std::string CONFIG =
      "general\n"
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 84493d2..1caefcf 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -22,6 +22,7 @@
  **/
 
 #include "test-common.hpp"
+#include "dummy-face.hpp"
 
 #include "lsdb.hpp"
 #include "nlsr.hpp"
@@ -31,16 +32,49 @@
 #include <ndn-cxx/util/time.hpp>
 
 namespace nlsr {
-
 namespace test {
 
-BOOST_FIXTURE_TEST_SUITE(TestLsdb, BaseFixture)
+using ndn::DummyFace;
+using ndn::shared_ptr;
+
+class LsdbFixture : public BaseFixture
+{
+public:
+  LsdbFixture()
+    : face(ndn::makeDummyFace())
+    , nlsr(g_ioService, g_scheduler, ndn::ref(*face))
+    , sync(*face, nlsr.getLsdb(), nlsr.getConfParameter())
+    , REGISTER_COMMAND_PREFIX("/localhost/nfd/rib")
+    , REGISTER_VERB("register")
+  {
+  }
+
+  void extractParameters(ndn::Interest& interest, ndn::Name::Component& verb,
+                         ndn::nfd::ControlParameters& extractedParameters)
+  {
+    const ndn::Name& name = interest.getName();
+    verb = name[REGISTER_COMMAND_PREFIX.size()];
+    const ndn::Name::Component& parameterComponent = name[REGISTER_COMMAND_PREFIX.size() + 1];
+
+    ndn::Block rawParameters = parameterComponent.blockFromValue();
+    extractedParameters.wireDecode(rawParameters);
+  }
+
+public:
+  shared_ptr<DummyFace> face;
+  Nlsr nlsr;
+  SyncLogicHandler sync;
+
+  ndn::Name REGISTER_COMMAND_PREFIX;
+  ndn::Name::Component REGISTER_VERB;
+};
+
+BOOST_FIXTURE_TEST_SUITE(TestLsdb, LsdbFixture)
 
 BOOST_AUTO_TEST_CASE(LsdbRemoveAndExists)
 {
   INIT_LOGGERS("/tmp", "DEBUG");
 
-  Nlsr nlsr1(g_ioService, g_scheduler);
   ndn::time::system_clock::TimePoint testTimePoint =  ndn::time::system_clock::now();
   NamePrefixList npl1;
 
@@ -51,12 +85,12 @@
   npl1.insert(s1);
   npl1.insert(s2);
 
-//For NameLsa lsType is name.
-//12 is seqNo, randomly generated.
-//1800 is the default life time.
+  //For NameLsa lsType is name.
+  //12 is seqNo, randomly generated.
+  //1800 is the default life time.
   NameLsa nlsa1(ndn::Name("/router1/1"), std::string("name"), 12, testTimePoint, npl1);
 
-  Lsdb lsdb1(nlsr1, g_scheduler);
+  Lsdb lsdb1(nlsr, g_scheduler);
 
   lsdb1.installNameLsa(nlsa1);
   lsdb1.writeNameLsdbLog();
@@ -68,6 +102,42 @@
   BOOST_CHECK_EQUAL(lsdb1.doesLsaExist(ndn::Name("/router1/1"), std::string("name")), false);
 }
 
+BOOST_AUTO_TEST_CASE(RegisterSyncPrefixOnFirstAdjLsaBuild)
+{
+  ConfParameter& conf = nlsr.getConfParameter();
+  conf.setNetwork("/ndn");
+  conf.setSiteName("/site");
+  conf.setRouterName("/%C1.router/this-router");
+
+  nlsr.initialize();
+
+  Lsdb& lsdb = nlsr.getLsdb();
+  face->processEvents(ndn::time::milliseconds(1));
+  face->m_sentInterests.clear();
+
+  // Should register Sync prefix
+  lsdb.buildAndInstallOwnAdjLsa();
+  face->processEvents(ndn::time::milliseconds(1));
+
+  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+
+  BOOST_REQUIRE(interests.size() > 0);
+
+  ndn::nfd::ControlParameters extractedParameters;
+  ndn::Name::Component verb;
+  extractParameters(interests[0], verb, extractedParameters);
+
+  BOOST_CHECK_EQUAL(verb, REGISTER_VERB);
+  BOOST_CHECK_EQUAL(extractedParameters.getName(), conf.getChronosyncPrefix());
+
+  // Should not register Sync prefix
+  face->m_sentInterests.clear();
+  lsdb.buildAndInstallOwnAdjLsa();
+  face->processEvents(ndn::time::milliseconds(1));
+
+  BOOST_CHECK_EQUAL(interests.size(), 0);
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } //namespace test
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
new file mode 100644
index 0000000..00839b1
--- /dev/null
+++ b/tests/test-sync-logic-handler.cpp
@@ -0,0 +1,172 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014  University of Memphis,
+ *                     Regents of the University of California
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR 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.
+ *
+ * NLSR 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
+ * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ **/
+
+#include "test-common.hpp"
+#include "dummy-face.hpp"
+
+#include "nlsr.hpp"
+#include "communication/sync-logic-handler.hpp"
+
+namespace nlsr {
+namespace test {
+
+using ndn::DummyFace;
+using ndn::shared_ptr;
+
+class SyncLogicFixture : public BaseFixture
+{
+public:
+  SyncLogicFixture()
+    : face(ndn::makeDummyFace())
+    , nlsr(g_ioService, g_scheduler, ndn::ref(*face))
+    , sync(*face, nlsr.getLsdb(), nlsr.getConfParameter())
+    , CONFIG_NETWORK("/ndn")
+    , CONFIG_SITE("/site")
+    , CONFIG_ROUTER_NAME("/%C1.Router/this-router")
+  {
+    nlsr.getConfParameter().setNetwork(CONFIG_NETWORK);
+    nlsr.getConfParameter().setSiteName(CONFIG_SITE);
+    nlsr.getConfParameter().setRouterName(CONFIG_ROUTER_NAME);
+    nlsr.getConfParameter().buildRouterPrefix();
+  }
+
+  void
+  receiveUpdate(std::string prefix, uint64_t seqNo)
+  {
+    Sync::MissingDataInfo info = {prefix, 0, seqNo};
+
+    std::vector<Sync::MissingDataInfo> updates;
+    updates.push_back(info);
+
+    face->processEvents(ndn::time::milliseconds(1));
+    face->m_sentInterests.clear();
+
+    sync.onNsyncUpdate(updates, NULL);
+
+    face->processEvents(ndn::time::milliseconds(1));
+  }
+
+public:
+  shared_ptr<DummyFace> face;
+  Nlsr nlsr;
+  SyncLogicHandler sync;
+
+  const std::string CONFIG_NETWORK;
+  const std::string CONFIG_SITE;
+  const std::string CONFIG_ROUTER_NAME;
+};
+
+BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
+
+BOOST_AUTO_TEST_CASE(UpdateForOther)
+{
+  std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
+                           CONFIG_SITE + "/%C1.Router/other-router/";
+
+  receiveUpdate(updateName, 1);
+
+  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+  BOOST_REQUIRE_EQUAL(interests.size(), 3);
+
+  std::vector<ndn::Interest>::iterator it = interests.begin();
+  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "name/");
+
+  ++it;
+  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "adjacency/");
+
+  ++it;
+  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "coordinate/");
+}
+
+BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
+{
+  std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
+                           CONFIG_SITE + CONFIG_ROUTER_NAME;
+
+  receiveUpdate(updateName, 1);
+
+  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+  BOOST_CHECK_EQUAL(interests.size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(MalformedUpdate)
+{
+  std::string updateName = CONFIG_SITE + nlsr.getConfParameter().getLsaPrefix().toUri() +
+                           CONFIG_ROUTER_NAME;
+
+  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+  BOOST_CHECK_EQUAL(interests.size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(SequenceNumber)
+{
+  std::string originRouter = CONFIG_NETWORK + CONFIG_SITE + "/%C1.Router/other-router/";
+
+  Lsdb& lsdb = nlsr.getLsdb();
+
+  // Install Name LSA
+  NamePrefixList nameList;
+  NameLsa lsa(originRouter, "name", 999, ndn::time::system_clock::TimePoint::max(), nameList);
+  lsdb.installNameLsa(lsa);
+
+  // Install Adj LSA
+  AdjacencyList adjList;
+  AdjLsa adjLsa(originRouter, "adjacency", 1000, ndn::time::system_clock::TimePoint::max(),
+                3 , adjList);
+  lsdb.installAdjLsa(adjLsa);
+
+  // Install Cor LSA
+  CoordinateLsa corLsa(originRouter, "coordinate", 1000, ndn::time::system_clock::TimePoint::max(),
+                       0,0);
+  lsdb.installCoordinateLsa(corLsa);
+
+  std::string updateName = nlsr.getConfParameter().getLsaPrefix().toUri() +
+                           CONFIG_SITE + "/%C1.Router/other-router/";
+
+  // Lower NameLSA sequence number
+  uint64_t lowerSeqNo = static_cast<uint64_t>(998) << 40;
+  receiveUpdate(updateName, lowerSeqNo);
+
+  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+  BOOST_REQUIRE_EQUAL(interests.size(), 0);
+
+  // Same NameLSA sequence number
+  uint64_t sameSeqNo = static_cast<uint64_t>(999) << 40;
+  receiveUpdate(updateName, sameSeqNo);
+
+  interests = face->m_sentInterests;
+  BOOST_REQUIRE_EQUAL(interests.size(), 0);
+
+  // Higher NameLSA sequence number
+  uint64_t higherSeqNo = static_cast<uint64_t>(1000) << 40;
+  receiveUpdate(updateName, higherSeqNo);
+
+  interests = face->m_sentInterests;
+  BOOST_REQUIRE_EQUAL(interests.size(), 1);
+
+  std::vector<ndn::Interest>::iterator it = interests.begin();
+  BOOST_CHECK_EQUAL(it->getName().getPrefix(-1), updateName + "name/");
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace test
+} // namespace nlsr
