diff --git a/tests/publisher/test-segment-publisher.cpp b/tests/publisher/test-segment-publisher.cpp
deleted file mode 100644
index a70e57f..0000000
--- a/tests/publisher/test-segment-publisher.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2018,  Regents of the University of California,
- *                           Arizona Board of Regents,
- *                           Colorado State University,
- *                           University Pierre & Marie Curie, Sorbonne University,
- *                           Washington University in St. Louis,
- *                           Beijing Institute of Technology,
- *                           The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD 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.
- *
- * NFD 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
- * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "publisher/segment-publisher.hpp"
-
-#include "../boost-test.hpp"
-#include "../test-common.hpp"
-
-#include <ndn-cxx/encoding/tlv.hpp>
-#include <ndn-cxx/util/dummy-client-face.hpp>
-
-#include <boost/mpl/int.hpp>
-#include <boost/mpl/vector.hpp>
-
-namespace nlsr {
-namespace tests {
-
-using namespace nlsr::test;
-
-template<int64_t N=10000>
-class TestSegmentPublisher : public SegmentPublisher<ndn::util::DummyClientFace>
-{
-public:
-  TestSegmentPublisher(ndn::util::DummyClientFace& face,
-                       ndn::KeyChain& keyChain,
-                       ndn::security::SigningInfo& signingInfo,
-                       const ndn::time::milliseconds freshnessPeriod)
-    : SegmentPublisher(face, keyChain, signingInfo, freshnessPeriod)
-    , m_totalPayloadLength(0)
-  {
-
-  }
-
-  virtual
-  ~TestSegmentPublisher()
-  {
-  }
-
-  uint16_t
-  getLimit() const
-  {
-    return N;
-  }
-
-  size_t
-  getTotalPayloadLength() const
-  {
-    return m_totalPayloadLength;
-  }
-
-protected:
-
-  virtual size_t
-  generate(ndn::EncodingBuffer& outBuffer)
-  {
-    size_t totalLength = 0;
-    for (int64_t i = 0; i < N; i++) {
-        totalLength += prependNonNegativeIntegerBlock(outBuffer, ndn::tlv::Content, i);
-    }
-
-    m_totalPayloadLength += totalLength;
-    return totalLength;
-  }
-
-protected:
-  size_t m_totalPayloadLength;
-};
-
-template<int64_t N>
-class SegmentPublisherFixture : public BaseFixture
-{
-public:
-  SegmentPublisherFixture()
-    : m_face(std::make_shared<ndn::util::DummyClientFace>(m_ioService, m_keyChain))
-    , m_expectedFreshnessPeriod(ndn::time::milliseconds(111))
-    , m_publisher(*m_face, m_keyChain, m_signingInfo, m_expectedFreshnessPeriod)
-    , m_publishingPrefix("/localhost/nfd/SegmentPublisherFixture")
-  {
-  }
-
-  void
-  validate(const ndn::Data& data)
-  {
-    BOOST_CHECK_EQUAL(data.getFreshnessPeriod(), m_expectedFreshnessPeriod);
-
-    ndn::Block payload = data.getContent();
-
-    m_buffer.appendByteArray(payload.value(), payload.value_size());
-
-    // uint64_t segmentNo = data.getName()[-1].toSegment();
-    if (data.getFinalBlock().value_or(ndn::name::Component("")) != data.getName()[-1]) {
-      return;
-    }
-
-    // wrap data in a single Content TLV for easy parsing
-    m_buffer.prependVarNumber(m_buffer.size());
-    m_buffer.prependVarNumber(ndn::tlv::Content);
-
-    BOOST_TEST_CHECKPOINT("creating parser");
-    ndn::Block parser(m_buffer.buf(), m_buffer.size());
-    BOOST_TEST_CHECKPOINT("parsing aggregated response");
-    parser.parse();
-
-    BOOST_REQUIRE_EQUAL(parser.elements_size(), m_publisher.getLimit());
-
-    uint64_t expectedNo = m_publisher.getLimit() - 1;
-    for (ndn::Block::element_const_iterator i = parser.elements_begin();
-         i != parser.elements_end();
-         ++i)
-      {
-        uint64_t number = readNonNegativeInteger(*i);
-        BOOST_REQUIRE_EQUAL(number, expectedNo);
-        --expectedNo;
-      }
-  }
-
-protected:
-  std::shared_ptr<ndn::util::DummyClientFace> m_face;
-  const ndn::time::milliseconds m_expectedFreshnessPeriod;
-  TestSegmentPublisher<N> m_publisher;
-  ndn::EncodingBuffer m_buffer;
-  ndn::security::SigningInfo m_signingInfo;
-  const ndn::Name m_publishingPrefix;
-};
-
-using boost::mpl::int_;
-typedef boost::mpl::vector<int_<10000>, int_<100>, int_<10>, int_<0> > DatasetSizes;
-
-BOOST_AUTO_TEST_SUITE(PublisherTestSegmentPublisher)
-
-BOOST_FIXTURE_TEST_CASE_TEMPLATE(Generate, T, DatasetSizes, SegmentPublisherFixture<T::value>)
-{
-  this->m_publisher.publish(this->m_publishingPrefix);
-  this->m_face->processEvents();
-
-  size_t nSegments = this->m_publisher.getTotalPayloadLength() /
-                     this->m_publisher.getMaxSegmentSize();
-  if (this->m_publisher.getTotalPayloadLength() % this->m_publisher.getMaxSegmentSize() != 0 ||
-      nSegments == 0)
-    ++nSegments;
-
-  BOOST_CHECK_EQUAL(this->m_face->sentData.size(), nSegments);
-  for (const ndn::Data& data : this->m_face->sentData) {
-    this->validate(data);
-  }
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace tests
-} // namespace nlsr
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 8a36113..2f9fefc 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -41,7 +41,7 @@
 {
 public:
   LsdbFixture()
-    : face(m_ioService, m_keyChain)
+    : face(m_ioService, m_keyChain, {true, true})
     , nlsr(m_ioService, m_scheduler, face, m_keyChain)
     , lsdb(nlsr.getLsdb())
     , conf(nlsr.getConfParameter())
@@ -172,6 +172,48 @@
   BOOST_CHECK_EQUAL(interests.size(), 0);
 }
 
+BOOST_AUTO_TEST_CASE(LsdbSegmentedData)
+{
+  // Add a lot of NameLSAs to exceed max packet size
+  ndn::Name lsaKey("/ndn/site/%C1.Router/this-router/NAME");
+
+  NameLsa* nameLsa = lsdb.findNameLsa(lsaKey);
+  uint64_t seqNo = nameLsa->getLsSeqNo();
+
+  ndn::Name prefix("/ndn/edu/memphis/netlab/research/nlsr/test/prefix/");
+
+  int nPrefixes = 0;
+  while (nameLsa->serialize().size() < ndn::MAX_NDN_PACKET_SIZE) {
+    nameLsa->addName(ndn::Name(prefix).appendNumber(++nPrefixes));
+  }
+  lsdb.installNameLsa(*nameLsa);
+
+  // Create another Lsdb and expressInterest
+  ndn::util::DummyClientFace face2(m_ioService, m_keyChain, {true, true});
+  face.linkTo(face2);
+  Nlsr nlsr2(m_ioService, m_scheduler, face2, m_keyChain);
+  std::string config = R"CONF(
+              trust-anchor
+                {
+                  type any
+                }
+            )CONF";
+  nlsr2.getValidator().load(config, "config-file-from-string");
+
+  Lsdb& lsdb2(nlsr2.getLsdb());
+
+  advanceClocks(ndn::time::milliseconds(1), 10);
+
+  ndn::Name interestName("/localhop/ndn/nlsr/LSA/site/%C1.Router/this-router/NAME");
+  interestName.appendNumber(seqNo);
+  // 0 == timeout count
+  lsdb2.expressInterest(interestName, 0);
+
+  advanceClocks(ndn::time::milliseconds(1), 10);
+
+  BOOST_CHECK_EQUAL(lsdb.getNameLsdb().front().getNpl(), lsdb2.getNameLsdb().front().getNpl());
+}
+
 BOOST_AUTO_TEST_CASE(SegmentLsaData)
 {
   ndn::Name lsaKey("/ndn/site/%C1.Router/this-router/NAME");
@@ -189,29 +231,21 @@
 
   std::string expectedDataContent = lsa->serialize();
 
-  ndn::Name interestName("/ndn/NLSR/LSA/site/%C1.Router/this-router/NAME/");
+  ndn::Name interestName("/localhop/ndn/nlsr/LSA/site/%C1.Router/this-router/NAME/");
   interestName.appendNumber(seqNo);
 
-  ndn::Interest interest(interestName);
-  lsdb.processInterest(ndn::Name(), interest);
-  advanceClocks(ndn::time::milliseconds(1), 10);
-  face.sentData.clear();
+  ndn::util::DummyClientFace face2(m_ioService, m_keyChain, {true, true});
+  face.linkTo(face2);
 
-  lsdb.processInterest(ndn::Name(), interest);
+  auto fetcher = ndn::util::SegmentFetcher::start(face2, ndn::Interest(interestName),
+                                                  ndn::security::v2::getAcceptAllValidator());
+  fetcher->onComplete.connect([&expectedDataContent] (ndn::ConstBufferPtr bufferPtr) {
+                                ndn::Block block(bufferPtr);
+                                BOOST_CHECK_EQUAL(expectedDataContent, readString(block));
+                              });
 
-  advanceClocks(ndn::time::milliseconds(1), 10);
-
-  std::string recvDataContent;
-  for (const ndn::Data& data : face.sentData)
-  {
-    const ndn::Block& nameBlock = data.getContent();
-    std::string nameBlockContent(reinterpret_cast<char const*>(nameBlock.value()),
-                                 nameBlock.value_size());
-
-    recvDataContent += nameBlockContent;
-  }
-
-  BOOST_CHECK_EQUAL(expectedDataContent, recvDataContent);
+  advanceClocks(ndn::time::milliseconds(1), 100);
+  fetcher->stop();
 }
 
 BOOST_AUTO_TEST_CASE(ReceiveSegmentedLsaData)
@@ -228,12 +262,11 @@
     lsa.addName(ndn::Name(prefix).appendNumber(nPrefixes));
   }
 
-  ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/NAME/");
+  ndn::Name interestName("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/NAME/");
   interestName.appendNumber(seqNo);
 
-  const ndn::ConstBufferPtr bufferPtr = std::make_shared<ndn::Buffer>(lsa.serialize().c_str(),
-                                                                 lsa.serialize().size());
-  lsdb.afterFetchLsa(bufferPtr, interestName);
+  ndn::Block block = ndn::encoding::makeStringBlock(ndn::tlv::Content, lsa.serialize());
+  lsdb.afterFetchLsa(block.getBuffer(), interestName);
 
   NameLsa* foundLsa = lsdb.findNameLsa(lsa.getKey());
   BOOST_REQUIRE(foundLsa != nullptr);
diff --git a/tests/test-statistics.cpp b/tests/test-statistics.cpp
index 51797e5..3e46c80 100644
--- a/tests/test-statistics.cpp
+++ b/tests/test-statistics.cpp
@@ -196,7 +196,7 @@
  */
 BOOST_AUTO_TEST_CASE(LsdbSendLsaInterest)
 {
-  const std::string interestPrefix("/ndn/NLSR/LSA/site/%C1.Router/router/");
+  const std::string interestPrefix("/localhop/ndn/nlsr/LSA/site/%C1.Router/router/");
   uint32_t seqNo = 1;
 
   // Adjacency LSA
@@ -240,7 +240,7 @@
 
   lsdb.installAdjLsa(*adjLsa);
 
-  const std::string interestPrefix("/ndn/NLSR/LSA/site/%C1.Router/this-router/");
+  const std::string interestPrefix("/localhop/ndn/nlsr/LSA/site/%C1.Router/this-router/");
 
   // Receive Adjacency LSA Interest
   receiveInterestAndCheckSentStats(interestPrefix,
@@ -302,37 +302,37 @@
   ndn::time::system_clock::TimePoint MAX_TIME = ndn::time::system_clock::TimePoint::max();
 
   // adjacency lsa
-  ndn::Name adjInterest("/ndn/NLSR/LSA/cs/%C1.Router/router1/ADJACENCY/");
+  ndn::Name adjInterest("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/ADJACENCY/");
   adjInterest.appendNumber(seqNo);
   AdjLsa aLsa(routerName, seqNo, MAX_TIME, 1, nlsr.getAdjacencyList());
   lsdb.installAdjLsa(aLsa);
 
-  const ndn::ConstBufferPtr aBuffer = std::make_shared<ndn::Buffer>(aLsa.serialize().c_str(),
-                                                                    aLsa.serialize().size());
-  lsdb.afterFetchLsa(aBuffer, adjInterest);
+  ndn::Block block = ndn::encoding::makeStringBlock(ndn::tlv::Content, aLsa.serialize());
+
+  lsdb.afterFetchLsa(block.getBuffer(), adjInterest);
   BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_ADJ_LSA_DATA), 1);
 
   // coordinate lsa
-  ndn::Name coordInterest("/ndn/NLSR/LSA/cs/%C1.Router/router1/COORDINATE/");
+  ndn::Name coordInterest("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/COORDINATE/");
   coordInterest.appendNumber(seqNo);
   std::vector<double> angles = {20.0, 30.0};
   CoordinateLsa cLsa(routerName, seqNo, MAX_TIME, 2.5, angles);
   lsdb.installCoordinateLsa(cLsa);
 
-  const ndn::ConstBufferPtr cBuffer = std::make_shared<ndn::Buffer>(cLsa.serialize().c_str(),
-                                                                   cLsa.serialize().size());
-  lsdb.afterFetchLsa(cBuffer, coordInterest);
+  block = ndn::encoding::makeStringBlock(ndn::tlv::Content, cLsa.serialize());
+
+  lsdb.afterFetchLsa(block.getBuffer(), coordInterest);
   BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_COORD_LSA_DATA), 1);
 
   // name lsa
-  ndn::Name interestName("/ndn/NLSR/LSA/cs/%C1.Router/router1/NAME/");
+  ndn::Name interestName("/localhop/ndn/nlsr/LSA/cs/%C1.Router/router1/NAME/");
   interestName.appendNumber(seqNo);
   NameLsa nLsa(routerName, seqNo, MAX_TIME, nlsr.getNamePrefixList());
   lsdb.installNameLsa(nLsa);
 
-  const ndn::ConstBufferPtr nBuffer = std::make_shared<ndn::Buffer>(nLsa.serialize().c_str(),
-                                                                   nLsa.serialize().size());
-  lsdb.afterFetchLsa(nBuffer, interestName);
+  block = ndn::encoding::makeStringBlock(ndn::tlv::Content, nLsa.serialize());
+
+  lsdb.afterFetchLsa(block.getBuffer(), interestName);
   BOOST_CHECK_EQUAL(collector.getStatistics().get(Statistics::PacketType::RCV_NAME_LSA_DATA), 1);
 
   // 3 lsa data types should be received
