diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index 30ffa7c..aa80343 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -22,12 +22,18 @@
 #ifndef NLSR_PUBLISHER_FIXTURE_HPP
 #define NLSR_PUBLISHER_FIXTURE_HPP
 
+#include "publisher/lsdb-dataset-interest-handler.hpp"
 #include "nlsr.hpp"
 
 #include "../boost-test.hpp"
 #include "../test-common.hpp"
 
 #include <ndn-cxx/util/dummy-client-face.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
+
+#include <boost/filesystem.hpp>
+
+using namespace ndn;
 
 namespace nlsr {
 namespace test {
@@ -36,10 +42,15 @@
 {
 public:
   PublisherFixture()
-    : face(std::make_shared<ndn::util::DummyClientFace>())
-    , nlsr(g_ioService, g_scheduler, std::ref(*face), g_keyChain)
-    , lsdb(nlsr, g_scheduler)
+    : face(g_ioService, keyChain, {true, true})
+    , nlsr(g_ioService, g_scheduler, face, g_keyChain)
+    , lsdb(nlsr.getLsdb())
   {
+    INIT_LOGGERS("/tmp/","TRACE");
+    nlsr.getConfParameter().setNetwork("/ndn");
+    nlsr.getConfParameter().setRouterName("/This/Router");
+    nlsr.initialize();
+    face.processEvents(ndn::time::milliseconds(10));
   }
 
   void
@@ -88,7 +99,6 @@
   {
     CoordinateLsa lsa(origin, 1, ndn::time::system_clock::now(),
                       radius, angle);
-
     return lsa;
   }
 
@@ -137,10 +147,11 @@
   }
 
 public:
-  std::shared_ptr<ndn::util::DummyClientFace> face;
-  Nlsr nlsr;
-  Lsdb lsdb;
+  ndn::util::DummyClientFace face;
   ndn::KeyChain keyChain;
+
+  Nlsr nlsr;
+  Lsdb& lsdb;
 };
 
 } // namespace test
diff --git a/tests/publisher/test-lsa-publisher.cpp b/tests/publisher/test-lsa-publisher.cpp
deleted file mode 100644
index 6a3045f..0000000
--- a/tests/publisher/test-lsa-publisher.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  The University of Memphis,
- *                           Regents of the University of California,
- *                           Arizona Board of Regents.
- *
- * 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 "publisher/lsa-publisher.hpp"
-#include "tlv/adjacency.hpp"
-#include "tlv/adjacency-lsa.hpp"
-#include "tlv/tlv-nlsr.hpp"
-
-#include "publisher-fixture.hpp"
-#include "../boost-test.hpp"
-
-namespace nlsr {
-namespace test {
-
-BOOST_FIXTURE_TEST_SUITE(PublisherTestLsaPublisher, PublisherFixture)
-
-BOOST_AUTO_TEST_CASE(AdjacencyLsaPublisherBasic)
-{
-  ndn::Name thisRouter("/RouterA");
-
-  // Adjacency LSA for RouterA
-  AdjLsa routerALsa;
-  routerALsa.setOrigRouter(thisRouter);
-  addAdjacency(routerALsa, "/RouterA/adjacency1", "udp://face-1", 10);
-  lsdb.installAdjLsa(routerALsa);
-
-  // Adjacency LSA for RouterB
-  AdjLsa routerBLsa;
-  routerBLsa.setOrigRouter("/RouterB");
-  routerBLsa.setLsSeqNo(5);
-  addAdjacency(routerBLsa, "/RouterB/adjacency1", "udp://face-1", 10);
-  addAdjacency(routerBLsa, "/RouterB/adjacency2", "udp://face-2", 20);
-  addAdjacency(routerBLsa, "/RouterB/adjacency3", "udp://face-3", 30);
-  lsdb.installAdjLsa(routerBLsa);
-
-  AdjacencyLsaPublisher publisher(lsdb, *face, keyChain);
-
-  ndn::Name publishingPrefix = ndn::Name(thisRouter);
-  publishingPrefix.append(Lsdb::NAME_COMPONENT).append(AdjacencyLsaPublisher::DATASET_COMPONENT);
-
-  publisher.publish(publishingPrefix);
-  face->processEvents(ndn::time::milliseconds(1));
-
-  BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
-  ndn::Block parser = face->sentData[0].getContent();
-  parser.parse();
-
-  // Check RouterB LSA
-  ndn::Block::element_const_iterator it = parser.elements_begin();
-  checkTlvAdjLsa(*it, routerBLsa);
-
-  // Check RouterA LSA
-  it++;
-  checkTlvAdjLsa(*it, routerALsa);
-}
-
-BOOST_AUTO_TEST_CASE(CoordinateLsaBasic)
-{
-  ndn::Name thisRouter("/RouterA");
-
-  std::vector<double> anglesA, anglesB, anglesC;
-  anglesA.push_back(20.00);
-  anglesB.push_back(543.21);
-  // Setting two angles for testing routerCLsa
-  anglesC.push_back(0.02);
-  anglesC.push_back(1.23);
-
-  CoordinateLsa routerALsa = createCoordinateLsa(thisRouter.toUri(), 10.0, anglesA);
-  lsdb.installCoordinateLsa(routerALsa);
-
-  CoordinateLsa routerBLsa = createCoordinateLsa("/RouterB", 123.45, anglesB);
-  lsdb.installCoordinateLsa(routerBLsa);
-
-  CoordinateLsa routerCLsa = createCoordinateLsa("/RouterC", 0.01, anglesC);
-  lsdb.installCoordinateLsa(routerCLsa);
-
-  CoordinateLsaPublisher publisher(lsdb, *face, keyChain);
-
-  ndn::Name publishingPrefix = ndn::Name(thisRouter);
-  publishingPrefix.append(Lsdb::NAME_COMPONENT).append(CoordinateLsaPublisher::DATASET_COMPONENT);
-
-  publisher.publish(publishingPrefix);
-  face->processEvents(ndn::time::milliseconds(1));
-
-  BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
-  ndn::Block parser = face->sentData[0].getContent();
-  parser.parse();
-
-  // Check RouterC LSA
-  ndn::Block::element_const_iterator it = parser.elements_begin();
-  checkTlvCoordinateLsa(*it, routerCLsa);
-
-  // Check RouterB LSA
-  ++it;
-  checkTlvCoordinateLsa(*it, routerBLsa);
-
-  // Check RouterA LSA
-  ++it;
-  checkTlvCoordinateLsa(*it, routerALsa);
-}
-
-BOOST_AUTO_TEST_CASE(NameLsaBasic)
-{
-  ndn::Name thisRouter("/RouterA");
-
-  // Name LSA for RouterA
-  NameLsa routerALsa;
-  routerALsa.setOrigRouter(thisRouter.toUri());
-  routerALsa.addName(ndn::Name(thisRouter).append("name1"));
-  lsdb.installNameLsa(routerALsa);
-
-  // Name LSA for RouterB
-  NameLsa routerBLsa;
-  routerBLsa.setOrigRouter("/RouterB");
-  routerBLsa.addName("/RouterB/name1");
-  routerBLsa.addName("/RouterB/name2");
-  routerBLsa.addName("/RouterB/name3");
-  lsdb.installNameLsa(routerBLsa);
-
-  NameLsaPublisher publisher(lsdb, *face, keyChain);
-
-  ndn::Name publishingPrefix = ndn::Name(thisRouter);
-  publishingPrefix.append(Lsdb::NAME_COMPONENT).append(NameLsaPublisher::DATASET_COMPONENT);
-
-  publisher.publish(publishingPrefix);
-  face->processEvents(ndn::time::milliseconds(1));
-
-  BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
-  ndn::Block parser = face->sentData[0].getContent();
-  parser.parse();
-
-  // Check RouterB LSA
-  ndn::Block::element_const_iterator it = parser.elements_begin();
-  checkTlvNameLsa(*it, routerBLsa);
-
-  // Check RouterA LSA
-  it++;
-  checkTlvNameLsa(*it, routerALsa);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace nlsr
diff --git a/tests/publisher/test-lsdb-dataset-interest-handler.cpp b/tests/publisher/test-lsdb-dataset-interest-handler.cpp
index e08d1f2..cd9fcf3 100644
--- a/tests/publisher/test-lsdb-dataset-interest-handler.cpp
+++ b/tests/publisher/test-lsdb-dataset-interest-handler.cpp
@@ -20,6 +20,7 @@
  **/
 
 #include "publisher/lsdb-dataset-interest-handler.hpp"
+#include "tests/test-common.hpp"
 #include "tlv/tlv-nlsr.hpp"
 
 #include "publisher-fixture.hpp"
@@ -31,13 +32,13 @@
 namespace test {
 
 void
-processDatasetInterest(std::shared_ptr<ndn::util::DummyClientFace> face,
+processDatasetInterest(ndn::util::DummyClientFace& face,
                        std::function<bool(const ndn::Block&)> isSameType)
 {
-  face->processEvents(ndn::time::milliseconds(1));
+  face.processEvents(ndn::time::milliseconds(30));
+  BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
 
-  BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
-  ndn::Block parser(face->sentData[0].getContent());
+  ndn::Block parser(face.sentData[0].getContent());
   parser.parse();
 
   ndn::Block::element_const_iterator it = parser.elements_begin();
@@ -46,23 +47,23 @@
 
   BOOST_CHECK(it == parser.elements_end());
 
-  face->sentData.clear();
+  face.sentData.clear();
 }
 
 void
-checkErrorResponse(std::shared_ptr<ndn::util::DummyClientFace> face, uint64_t expectedCode)
+checkErrorResponse(ndn::util::DummyClientFace& face, uint64_t expectedCode)
 {
-  BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
+  BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
 
-  ndn::nfd::ControlResponse response(face->sentData[0].getContent().blockFromValue());
+  ndn::nfd::ControlResponse response(face.sentData[0].getContent().blockFromValue());
   BOOST_CHECK_EQUAL(response.getCode(), expectedCode);
 
-  face->sentData.clear();
+  face.sentData.clear();
 }
 
 BOOST_FIXTURE_TEST_SUITE(PublisherTestLsdbDatasetInterestHandler, PublisherFixture)
 
-BOOST_AUTO_TEST_CASE(Basic)
+BOOST_AUTO_TEST_CASE(Localhost)
 {
   // Install adjacency LSA
   AdjLsa adjLsa;
@@ -82,109 +83,61 @@
   nameLsa.addName("/RouterA/name1");
   lsdb.installNameLsa(nameLsa);
 
-  ndn::Name thisRouter("/This/Router");
-  LsdbDatasetInterestHandler publisher(lsdb, *face, keyChain);
-  publisher.setRouterNameCommandPrefix(thisRouter);
-
-  publisher.startListeningOnLocalhost();
-
-  face->processEvents(ndn::time::milliseconds(10));
-
-  // Localhost prefix
-  ndn::Name localhostCommandPrefix = publisher.getLocalhostCommandPrefix();
-
   // Request adjacency LSAs
-  face->receive(ndn::Interest(ndn::Name(localhostCommandPrefix).append("adjacencies")));
+  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("adjacencies")));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
 
   // Request coordinate LSAs
-  face->receive(ndn::Interest(ndn::Name(localhostCommandPrefix).append("coordinates")));
+  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("coordinates")));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
 
   // Request Name LSAs
-  face->receive(ndn::Interest(ndn::Name(localhostCommandPrefix).append("names")));
+  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("names")));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
 
   // Request LSDB Status
-  face->receive(ndn::Interest(ndn::Name(localhostCommandPrefix).append("list")));
-  processDatasetInterest(face,
-    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::LsdbStatus; });
-
-  // Router name prefix
-  ndn::Name routerCommandPrefix = publisher.getLocalhostCommandPrefix();
-
-  // Request adjacency LSAs
-  face->receive(ndn::Interest(ndn::Name(routerCommandPrefix).append("adjacencies")));
-  processDatasetInterest(face,
-    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
-
-  // Request coordinate LSAs
-  face->receive(ndn::Interest(ndn::Name(routerCommandPrefix).append("coordinates")));
-  processDatasetInterest(face,
-    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
-
-  // Request Name LSAs
-  face->receive(ndn::Interest(ndn::Name(routerCommandPrefix).append("names")));
-  processDatasetInterest(face,
-    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
-
-  // Request LSDB Status
-  face->receive(ndn::Interest(ndn::Name(routerCommandPrefix).append("list")));
+  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("list")));
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::LsdbStatus; });
 }
 
-BOOST_AUTO_TEST_CASE(InvalidCommand)
+
+BOOST_AUTO_TEST_CASE(Routername)
 {
-  ndn::Name thisRouter("/This/Router");
-  LsdbDatasetInterestHandler publisher(lsdb, *face, keyChain);
-  publisher.setRouterNameCommandPrefix(thisRouter);
+  //Install adjacencies LSA
+  AdjLsa adjLsa;
+  adjLsa.setOrigRouter("/RouterA");
+  addAdjacency(adjLsa, "/RouterA/adjacency1", "udp://face-1", 10);
+  lsdb.installAdjLsa(adjLsa);
 
-  // Localhost prefix
-  publisher.startListeningOnLocalhost();
-  face->processEvents(ndn::time::milliseconds(10));
+  std::vector<double> angles = {20.00, 30.00};
 
-  ndn::Name localhostCommandPrefix = publisher.getLocalhostCommandPrefix();
+  //Install coordinate LSA
+  CoordinateLsa coordinateLsa = createCoordinateLsa("/RouterA", 10.0, angles);
+  lsdb.installCoordinateLsa(coordinateLsa);
 
-  // Unsupported command
-  face->receive(ndn::Interest(ndn::Name(localhostCommandPrefix).append("unsupported")));
-  face->processEvents(ndn::time::milliseconds(1));
+  // Request adjacency LSAs
+  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("adjacencies")));
+  processDatasetInterest(face,
+    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::AdjacencyLsa; });
 
-  checkErrorResponse(face, LsdbDatasetInterestHandler::ERROR_CODE_UNSUPPORTED_COMMAND);
+  // Request coordinate LSAs
+  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("coordinates")));
+  processDatasetInterest(face,
+    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::CoordinateLsa; });
 
-  // Long malformed command
-  face->receive(
-    ndn::Interest(ndn::Name(localhostCommandPrefix).append("extra").append("malformed")));
-  face->processEvents(ndn::time::milliseconds(1));
+  // Request Name LSAs
+  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("names")));
+  processDatasetInterest(face,
+    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
 
-  checkErrorResponse(face, LsdbDatasetInterestHandler::ERROR_CODE_MALFORMED_COMMAND);
-
-  // Router name prefix
-  publisher.startListeningOnRouterPrefix();
-  face->processEvents(ndn::time::milliseconds(10));
-
-  ndn::Name remoteCommandPrefix = publisher.getRouterNameCommandPrefix();
-
-  // Unsupported command
-  face->receive(ndn::Interest(ndn::Name(remoteCommandPrefix).append("unsupported")));
-  face->processEvents(ndn::time::milliseconds(1));
-
-  checkErrorResponse(face, LsdbDatasetInterestHandler::ERROR_CODE_UNSUPPORTED_COMMAND);
-
-  // Long malformed command
-  face->receive(ndn::Interest(ndn::Name(remoteCommandPrefix).append("extra").append("malformed")));
-  face->processEvents(ndn::time::milliseconds(1));
-
-  checkErrorResponse(face, LsdbDatasetInterestHandler::ERROR_CODE_MALFORMED_COMMAND);
-
-  // Short malformed command
-  face->receive(ndn::Interest(ndn::Name(thisRouter).append("malformed")));
-  face->processEvents(ndn::time::milliseconds(1));
-
-  BOOST_CHECK_EQUAL(face->sentData.size(), 0);
+  // Request LSDB Status
+  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("list")));
+  processDatasetInterest(face,
+    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::LsdbStatus; });
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/publisher/test-lsdb-status-publisher.cpp b/tests/publisher/test-lsdb-status-publisher.cpp
deleted file mode 100644
index c9412ad..0000000
--- a/tests/publisher/test-lsdb-status-publisher.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017,  The University of Memphis,
- *                           Regents of the University of California,
- *                           Arizona Board of Regents.
- *
- * 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 "publisher/lsdb-status-publisher.hpp"
-#include "tlv/lsdb-status.hpp"
-#include "tlv/tlv-nlsr.hpp"
-
-#include "publisher-fixture.hpp"
-#include "../boost-test.hpp"
-
-namespace nlsr {
-namespace test {
-
-BOOST_FIXTURE_TEST_SUITE(PublisherTestLsdbStatusPublisher, PublisherFixture)
-
-BOOST_AUTO_TEST_CASE(Basic)
-{
-  // Install adjacency LSAs
-  // Adjacency LSA for RouterA
-  AdjLsa routerAAdjLsa;
-  routerAAdjLsa.setOrigRouter("/RouterA");
-  addAdjacency(routerAAdjLsa, "/RouterA/adjacency1", "udp://face-1", 10);
-  lsdb.installAdjLsa(routerAAdjLsa);
-
-  // Adjacency LSA for RouterB
-  AdjLsa routerBAdjLsa;
-  routerBAdjLsa.setOrigRouter("/RouterB");
-  routerBAdjLsa.setLsSeqNo(5);
-  addAdjacency(routerBAdjLsa, "/RouterB/adjacency1", "udp://face-1", 10);
-  addAdjacency(routerBAdjLsa, "/RouterB/adjacency2", "udp://face-2", 20);
-  addAdjacency(routerBAdjLsa, "/RouterB/adjacency3", "udp://face-3", 30);
-  lsdb.installAdjLsa(routerBAdjLsa);
-
-  std::vector<double> anglesA = {20.00},
-                      anglesB = {543.21},
-                      anglesC = {0.02, 2.25};
-
-  // Install coordinate LSAs
-  CoordinateLsa routerACorLsa = createCoordinateLsa("/RouterA", 10.0, anglesA);
-  lsdb.installCoordinateLsa(routerACorLsa);
-
-  CoordinateLsa routerBCorLsa = createCoordinateLsa("/RouterB", 123.45, anglesB);
-  lsdb.installCoordinateLsa(routerBCorLsa);
-
-  CoordinateLsa routerCCorLsa = createCoordinateLsa("/RouterC", 0.01, anglesC);
-  lsdb.installCoordinateLsa(routerCCorLsa);
-
-  // Install Name LSAs
-  // Name LSA for RouterA
-  NameLsa routerANameLsa;
-  routerANameLsa.setOrigRouter("/RouterA");
-  routerANameLsa.addName("/RouterA/name1");
-  lsdb.installNameLsa(routerANameLsa);
-
-  // Name LSA for RouterB
-  NameLsa routerBNameLsa;
-  routerBNameLsa.setOrigRouter("/RouterB");
-  routerBNameLsa.addName("/RouterB/name1");
-  routerBNameLsa.addName("/RouterB/name2");
-  routerBNameLsa.addName("/RouterB/name3");
-  lsdb.installNameLsa(routerBNameLsa);
-
-  ndn::Name thisRouter("/This/Router");
-  AdjacencyLsaPublisher adjacencyLsaPublisher(lsdb, *face, keyChain);
-  CoordinateLsaPublisher coordinateLsaPublisher(lsdb, *face, keyChain);
-  NameLsaPublisher nameLsaPublisher(lsdb, *face, keyChain);
-
-  LsdbStatusPublisher publisher(lsdb, *face, keyChain,
-                                adjacencyLsaPublisher,
-                                coordinateLsaPublisher,
-                                nameLsaPublisher);
-
-  ndn::Name publishingPrefix = ndn::Name(thisRouter);
-  publishingPrefix.append(Lsdb::NAME_COMPONENT).append(LsdbStatusPublisher::DATASET_COMPONENT);
-
-  publisher.publish(publishingPrefix);
-  face->processEvents(ndn::time::milliseconds(1));
-
-  BOOST_REQUIRE_EQUAL(face->sentData.size(), 1);
-
-  ndn::Block parser = face->sentData[0].getContent();
-  parser.parse();
-
-  ndn::Block::element_const_iterator it = parser.elements_begin();
-
-  BOOST_CHECK_EQUAL(it->type(), ndn::tlv::nlsr::LsdbStatus);
-
-  tlv::LsdbStatus lsdbStatusTlv;
-  BOOST_REQUIRE_NO_THROW(lsdbStatusTlv.wireDecode(*it));
-
-  BOOST_CHECK_EQUAL(lsdbStatusTlv.hasAdjacencyLsas(), true);
-
-  // Check adjacency LSAs
-  std::list<tlv::AdjacencyLsa>::const_iterator adjLsaIt = lsdbStatusTlv.getAdjacencyLsas().begin();
-  checkTlvAdjLsa(*adjLsaIt, routerAAdjLsa);
-
-  ++adjLsaIt;
-  checkTlvAdjLsa(*adjLsaIt, routerBAdjLsa);
-
-  // Check coordinate LSAs
-  std::list<tlv::CoordinateLsa>::const_iterator corLsaIt =
-    lsdbStatusTlv.getCoordinateLsas().begin();
-  checkTlvCoordinateLsa(*corLsaIt, routerACorLsa);
-
-  ++corLsaIt;
-  checkTlvCoordinateLsa(*corLsaIt, routerBCorLsa);
-
-  ++corLsaIt;
-  checkTlvCoordinateLsa(*corLsaIt, routerCCorLsa);
-
-  // Check Name LSAs
-  std::list<tlv::NameLsa>::const_iterator nameLsaIt = lsdbStatusTlv.getNameLsas().begin();
-  checkTlvNameLsa(*nameLsaIt, routerANameLsa);
-
-  ++nameLsaIt;
-  checkTlvNameLsa(*nameLsaIt, routerBNameLsa);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace nlsr
