diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index b1e934f..2299927 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -30,10 +30,11 @@
 #include "face/protocol-factory.hpp"
 #include "fw/face-table.hpp"
 
-#include <boost/logic/tribool.hpp>
-
 #include <ndn-cxx/lp/tags.hpp>
 #include <ndn-cxx/mgmt/nfd/channel-status.hpp>
+#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
+#include <ndn-cxx/mgmt/nfd/face-query-filter.hpp>
+#include <ndn-cxx/mgmt/nfd/face-status.hpp>
 
 namespace nfd {
 
@@ -47,19 +48,14 @@
   , m_faceTable(faceSystem.getFaceTable())
 {
   // register handlers for ControlCommand
-  registerCommandHandler<ndn::nfd::FaceCreateCommand>("create",
-    bind(&FaceManager::createFace, this, _2, _3, _4, _5));
-
-  registerCommandHandler<ndn::nfd::FaceUpdateCommand>("update",
-    bind(&FaceManager::updateFace, this, _2, _3, _4, _5));
-
-  registerCommandHandler<ndn::nfd::FaceDestroyCommand>("destroy",
-    bind(&FaceManager::destroyFace, this, _2, _3, _4, _5));
+  registerCommandHandler<ndn::nfd::FaceCreateCommand>("create", bind(&FaceManager::createFace, this, _4, _5));
+  registerCommandHandler<ndn::nfd::FaceUpdateCommand>("update", bind(&FaceManager::updateFace, this, _3, _4, _5));
+  registerCommandHandler<ndn::nfd::FaceDestroyCommand>("destroy", bind(&FaceManager::destroyFace, this, _4, _5));
 
   // register handlers for StatusDataset
-  registerStatusDatasetHandler("list", bind(&FaceManager::listFaces, this, _1, _2, _3));
-  registerStatusDatasetHandler("channels", bind(&FaceManager::listChannels, this, _1, _2, _3));
-  registerStatusDatasetHandler("query", bind(&FaceManager::queryFaces, this, _1, _2, _3));
+  registerStatusDatasetHandler("list", bind(&FaceManager::listFaces, this, _3));
+  registerStatusDatasetHandler("channels", bind(&FaceManager::listChannels, this, _3));
+  registerStatusDatasetHandler("query", bind(&FaceManager::queryFaces, this, _2, _3));
 
   // register notification stream
   m_postNotification = registerNotificationStream("events");
@@ -73,8 +69,7 @@
 }
 
 void
-FaceManager::createFace(const Name& topPrefix, const Interest& interest,
-                        const ControlParameters& parameters,
+FaceManager::createFace(const ControlParameters& parameters,
                         const ndn::mgmt::CommandContinuation& done)
 {
   FaceUri remoteUri;
@@ -134,8 +129,13 @@
   }
   try {
     factory->createFace({remoteUri, localUri, faceParams},
-                        bind(&FaceManager::afterCreateFaceSuccess, this, parameters, _1, done),
-                        bind(&FaceManager::afterCreateFaceFailure, this, _1, _2, done));
+                        [this, parameters, done] (const auto& face) {
+                          this->afterCreateFaceSuccess(face, parameters, done);
+                        },
+                        [done] (uint32_t status, const std::string& reason) {
+                          NFD_LOG_DEBUG("Face creation failed: " << reason);
+                          done(ControlResponse(status, reason));
+                        });
   }
   catch (const std::runtime_error& error) {
     NFD_LOG_ERROR("Face creation failed: " << error.what());
@@ -149,15 +149,61 @@
   }
 }
 
+template<typename T>
+static void
+copyMtu(const Face& face, T& to)
+{
+  auto transport = face.getTransport();
+  BOOST_ASSERT(transport != nullptr);
+
+  if (transport->getMtu() > 0) {
+    to.setMtu(std::min(static_cast<size_t>(transport->getMtu()), ndn::MAX_NDN_PACKET_SIZE));
+  }
+  else if (transport->getMtu() == face::MTU_UNLIMITED) {
+    to.setMtu(ndn::MAX_NDN_PACKET_SIZE);
+  }
+}
+
+static ControlParameters
+makeUpdateFaceResponse(const Face& face)
+{
+  ControlParameters params;
+  params.setFaceId(face.getId())
+        .setFacePersistency(face.getPersistency());
+
+  auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
+  if (linkService != nullptr) {
+    const auto& options = linkService->getOptions();
+    params.setBaseCongestionMarkingInterval(options.baseCongestionMarkingInterval)
+          .setDefaultCongestionThreshold(options.defaultCongestionThreshold)
+          .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, options.allowLocalFields, false)
+          .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, options.reliabilityOptions.isEnabled, false)
+          .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, options.allowCongestionMarking, false);
+  }
+
+  return params;
+}
+
+static ControlParameters
+makeCreateFaceResponse(const Face& face)
+{
+  ControlParameters params = makeUpdateFaceResponse(face);
+  params.setUri(face.getRemoteUri().toString())
+        .setLocalUri(face.getLocalUri().toString());
+
+  copyMtu(face, params);
+
+  return params;
+}
+
 void
-FaceManager::afterCreateFaceSuccess(const ControlParameters& parameters,
-                                    const shared_ptr<Face>& face,
+FaceManager::afterCreateFaceSuccess(const shared_ptr<Face>& face,
+                                    const ControlParameters& parameters,
                                     const ndn::mgmt::CommandContinuation& done)
 {
-  if (face->getId() != face::INVALID_FACEID) {// Face already exists
+  if (face->getId() != face::INVALID_FACEID) { // Face already exists
     NFD_LOG_TRACE("Attempted to create duplicate face of " << face->getId());
-
-    ControlParameters response = collectFaceProperties(*face, true);
+    ControlParameters response = makeCreateFaceResponse(*face);
     done(ControlResponse(409, "Face with remote URI already exists").setBody(response.wireEncode()));
     return;
   }
@@ -171,29 +217,47 @@
 
   m_faceTable.add(face);
 
-  ControlParameters response = collectFaceProperties(*face, true);
+  ControlParameters response = makeCreateFaceResponse(*face);
   done(ControlResponse(200, "OK").setBody(response.wireEncode()));
 }
 
-void
-FaceManager::afterCreateFaceFailure(uint32_t status,
-                                    const std::string& reason,
-                                    const ndn::mgmt::CommandContinuation& done)
+static void
+updateLinkServiceOptions(Face& face, const ControlParameters& parameters)
 {
-  NFD_LOG_DEBUG("Face creation failed: " << reason);
+  auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
+  if (linkService == nullptr) {
+    return;
+  }
+  auto options = linkService->getOptions();
 
-  done(ControlResponse(status, reason));
+  if (parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) &&
+      face.getScope() == ndn::nfd::FACE_SCOPE_LOCAL) {
+    options.allowLocalFields = parameters.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED);
+  }
+  if (parameters.hasFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)) {
+    options.reliabilityOptions.isEnabled = parameters.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED);
+  }
+  if (parameters.hasFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)) {
+    options.allowCongestionMarking = parameters.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED);
+  }
+  if (parameters.hasBaseCongestionMarkingInterval()) {
+    options.baseCongestionMarkingInterval = parameters.getBaseCongestionMarkingInterval();
+  }
+  if (parameters.hasDefaultCongestionThreshold()) {
+    options.defaultCongestionThreshold = parameters.getDefaultCongestionThreshold();
+  }
+
+  linkService->setOptions(options);
 }
 
 void
-FaceManager::updateFace(const Name& topPrefix, const Interest& interest,
+FaceManager::updateFace(const Interest& interest,
                         const ControlParameters& parameters,
                         const ndn::mgmt::CommandContinuation& done)
 {
   FaceId faceId = parameters.getFaceId();
-  if (faceId == 0) {
-    // Self-updating
-    shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = interest.getTag<lp::IncomingFaceIdTag>();
+  if (faceId == 0) { // Self-update
+    auto incomingFaceIdTag = interest.getTag<lp::IncomingFaceIdTag>();
     if (incomingFaceIdTag == nullptr) {
       NFD_LOG_TRACE("unable to determine face for self-update");
       done(ControlResponse(404, "No FaceId specified and IncomingFaceId not available"));
@@ -203,7 +267,6 @@
   }
 
   Face* face = m_faceTable.get(faceId);
-
   if (face == nullptr) {
     NFD_LOG_TRACE("invalid face specified");
     done(ControlResponse(404, "Specified face does not exist"));
@@ -242,18 +305,15 @@
   if (parameters.hasFacePersistency()) {
     face->setPersistency(parameters.getFacePersistency());
   }
-  setLinkServiceOptions(*face, parameters);
+  updateLinkServiceOptions(*face, parameters);
 
-  // Set ControlResponse fields
-  response = collectFaceProperties(*face, false);
-  response.unsetMtu(); // This parameter is only included with the response to faces/create and FaceStatus
-
+  // Prepare and send ControlResponse
+  response = makeUpdateFaceResponse(*face);
   done(ControlResponse(200, "OK").setBody(response.wireEncode()));
 }
 
 void
-FaceManager::destroyFace(const Name& topPrefix, const Interest& interest,
-                         const ControlParameters& parameters,
+FaceManager::destroyFace(const ControlParameters& parameters,
                          const ndn::mgmt::CommandContinuation& done)
 {
   Face* face = m_faceTable.get(parameters.getFaceId());
@@ -264,83 +324,75 @@
   done(ControlResponse(200, "OK").setBody(parameters.wireEncode()));
 }
 
-void
-FaceManager::setLinkServiceOptions(Face& face,
-                                   const ControlParameters& parameters)
+template<typename T>
+static void
+copyFaceProperties(const Face& face, T& to)
 {
-  auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
-  BOOST_ASSERT(linkService != nullptr);
+  to.setFaceId(face.getId())
+    .setRemoteUri(face.getRemoteUri().toString())
+    .setLocalUri(face.getLocalUri().toString())
+    .setFaceScope(face.getScope())
+    .setFacePersistency(face.getPersistency())
+    .setLinkType(face.getLinkType());
 
-  auto options = linkService->getOptions();
-  if (parameters.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED) &&
-      face.getScope() == ndn::nfd::FACE_SCOPE_LOCAL) {
-    options.allowLocalFields = parameters.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED);
+  auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
+  if (linkService != nullptr) {
+    const auto& options = linkService->getOptions();
+    to.setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, options.allowLocalFields)
+      .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, options.reliabilityOptions.isEnabled)
+      .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, options.allowCongestionMarking);
   }
-  if (parameters.hasFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)) {
-    options.reliabilityOptions.isEnabled = parameters.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED);
-  }
-  if (parameters.hasFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)) {
-    options.allowCongestionMarking = parameters.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED);
-  }
-  if (parameters.hasBaseCongestionMarkingInterval()) {
-    options.baseCongestionMarkingInterval = parameters.getBaseCongestionMarkingInterval();
-  }
-  if (parameters.hasDefaultCongestionThreshold()) {
-    options.defaultCongestionThreshold = parameters.getDefaultCongestionThreshold();
-  }
-  linkService->setOptions(options);
 }
 
-ControlParameters
-FaceManager::collectFaceProperties(const Face& face, bool wantUris)
+static ndn::nfd::FaceStatus
+makeFaceStatus(const Face& face, const time::steady_clock::TimePoint& now)
 {
+  ndn::nfd::FaceStatus status;
+  copyFaceProperties(face, status);
+
+  auto expirationTime = face.getExpirationTime();
+  if (expirationTime != time::steady_clock::TimePoint::max()) {
+    status.setExpirationPeriod(std::max(0_ms,
+                                        time::duration_cast<time::milliseconds>(expirationTime - now)));
+  }
+
   auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
-  BOOST_ASSERT(linkService != nullptr);
-  auto options = linkService->getOptions();
-
-  auto transport = face.getTransport();
-  BOOST_ASSERT(transport != nullptr);
-
-  ControlParameters params;
-  params.setFaceId(face.getId())
-        .setFacePersistency(face.getPersistency())
-        .setBaseCongestionMarkingInterval(options.baseCongestionMarkingInterval)
-        .setDefaultCongestionThreshold(options.defaultCongestionThreshold)
-        .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, options.allowLocalFields, false)
-        .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, options.reliabilityOptions.isEnabled, false)
-        .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, options.allowCongestionMarking, false);
-
-  if (transport->getMtu() > 0) {
-    params.setMtu(std::min<uint64_t>(transport->getMtu(), ndn::MAX_NDN_PACKET_SIZE));
-  }
-  else if (transport->getMtu() == face::MTU_UNLIMITED) {
-    params.setMtu(ndn::MAX_NDN_PACKET_SIZE);
+  if (linkService != nullptr) {
+    const auto& options = linkService->getOptions();
+    status.setBaseCongestionMarkingInterval(options.baseCongestionMarkingInterval)
+          .setDefaultCongestionThreshold(options.defaultCongestionThreshold);
   }
 
-  if (wantUris) {
-    params.setUri(face.getRemoteUri().toString())
-          .setLocalUri(face.getLocalUri().toString());
-  }
-  return params;
+  copyMtu(face, status);
+
+  const auto& counters = face.getCounters();
+  status.setNInInterests(counters.nInInterests)
+        .setNOutInterests(counters.nOutInterests)
+        .setNInData(counters.nInData)
+        .setNOutData(counters.nOutData)
+        .setNInNacks(counters.nInNacks)
+        .setNOutNacks(counters.nOutNacks)
+        .setNInBytes(counters.nInBytes)
+        .setNOutBytes(counters.nOutBytes);
+
+  return status;
 }
 
 void
-FaceManager::listFaces(const Name& topPrefix, const Interest& interest,
-                       ndn::mgmt::StatusDatasetContext& context)
+FaceManager::listFaces(ndn::mgmt::StatusDatasetContext& context)
 {
   auto now = time::steady_clock::now();
-  for (const Face& face : m_faceTable) {
-    ndn::nfd::FaceStatus status = collectFaceStatus(face, now);
+  for (const auto& face : m_faceTable) {
+    ndn::nfd::FaceStatus status = makeFaceStatus(face, now);
     context.append(status.wireEncode());
   }
   context.end();
 }
 
 void
-FaceManager::listChannels(const Name& topPrefix, const Interest& interest,
-                          ndn::mgmt::StatusDatasetContext& context)
+FaceManager::listChannels(ndn::mgmt::StatusDatasetContext& context)
 {
-  std::set<const face::ProtocolFactory*> factories = m_faceSystem.listProtocolFactories();
+  auto factories = m_faceSystem.listProtocolFactories();
   for (const auto* factory : factories) {
     for (const auto& channel : factory->getChannels()) {
       ndn::nfd::ChannelStatus entry;
@@ -351,34 +403,8 @@
   context.end();
 }
 
-void
-FaceManager::queryFaces(const Name& topPrefix, const Interest& interest,
-                        ndn::mgmt::StatusDatasetContext& context)
-{
-  ndn::nfd::FaceQueryFilter faceFilter;
-  const Name& query = interest.getName();
-  try {
-    faceFilter.wireDecode(query[-1].blockFromValue());
-  }
-  catch (const tlv::Error& e) {
-    NFD_LOG_DEBUG("Malformed query filter: " << e.what());
-    return context.reject(ControlResponse(400, "Malformed filter"));
-  }
-
-  auto now = time::steady_clock::now();
-  for (const Face& face : m_faceTable) {
-    if (!matchFilter(faceFilter, face)) {
-      continue;
-    }
-    ndn::nfd::FaceStatus status = collectFaceStatus(face, now);
-    context.append(status.wireEncode());
-  }
-
-  context.end();
-}
-
-bool
-FaceManager::matchFilter(const ndn::nfd::FaceQueryFilter& filter, const Face& face)
+static bool
+matchFilter(const ndn::nfd::FaceQueryFilter& filter, const Face& face)
 {
   if (filter.hasFaceId() &&
       filter.getFaceId() != static_cast<uint64_t>(face.getId())) {
@@ -419,61 +445,27 @@
   return true;
 }
 
-ndn::nfd::FaceStatus
-FaceManager::collectFaceStatus(const Face& face, const time::steady_clock::TimePoint& now)
-{
-  ndn::nfd::FaceStatus status;
-
-  collectFaceProperties(face, status);
-
-  time::steady_clock::TimePoint expirationTime = face.getExpirationTime();
-  if (expirationTime != time::steady_clock::TimePoint::max()) {
-    status.setExpirationPeriod(std::max(0_ms,
-                                        time::duration_cast<time::milliseconds>(expirationTime - now)));
-  }
-
-  // Get LinkService options
-  auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
-  if (linkService != nullptr) {
-    auto linkServiceOptions = linkService->getOptions();
-    status.setBaseCongestionMarkingInterval(linkServiceOptions.baseCongestionMarkingInterval);
-    status.setDefaultCongestionThreshold(linkServiceOptions.defaultCongestionThreshold);
-  }
-
-  const face::FaceCounters& counters = face.getCounters();
-  status.setNInInterests(counters.nInInterests)
-        .setNOutInterests(counters.nOutInterests)
-        .setNInData(counters.nInData)
-        .setNOutData(counters.nOutData)
-        .setNInNacks(counters.nInNacks)
-        .setNOutNacks(counters.nOutNacks)
-        .setNInBytes(counters.nInBytes)
-        .setNOutBytes(counters.nOutBytes);
-
-  return status;
-}
-
-template<typename FaceTraits>
 void
-FaceManager::collectFaceProperties(const Face& face, FaceTraits& traits)
+FaceManager::queryFaces(const Interest& interest,
+                        ndn::mgmt::StatusDatasetContext& context)
 {
-  traits.setFaceId(face.getId())
-        .setRemoteUri(face.getRemoteUri().toString())
-        .setLocalUri(face.getLocalUri().toString())
-        .setFaceScope(face.getScope())
-        .setFacePersistency(face.getPersistency())
-        .setLinkType(face.getLinkType());
-
-  // Set Flag bits
-  auto linkService = dynamic_cast<face::GenericLinkService*>(face.getLinkService());
-  if (linkService != nullptr) {
-    auto linkServiceOptions = linkService->getOptions();
-    traits.setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, linkServiceOptions.allowLocalFields);
-    traits.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED,
-                      linkServiceOptions.reliabilityOptions.isEnabled);
-    traits.setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED,
-                      linkServiceOptions.allowCongestionMarking);
+  ndn::nfd::FaceQueryFilter faceFilter;
+  try {
+    faceFilter.wireDecode(interest.getName()[-1].blockFromValue());
   }
+  catch (const tlv::Error& e) {
+    NFD_LOG_DEBUG("Malformed query filter: " << e.what());
+    return context.reject(ControlResponse(400, "Malformed filter"));
+  }
+
+  auto now = time::steady_clock::now();
+  for (const auto& face : m_faceTable) {
+    if (matchFilter(faceFilter, face)) {
+      ndn::nfd::FaceStatus status = makeFaceStatus(face, now);
+      context.append(status.wireEncode());
+    }
+  }
+  context.end();
 }
 
 void
@@ -481,7 +473,7 @@
 {
   ndn::nfd::FaceEventNotification notification;
   notification.setKind(kind);
-  collectFaceProperties(face, notification);
+  copyFaceProperties(face, notification);
 
   m_postNotification(notification.wireEncode());
 }
diff --git a/daemon/mgmt/face-manager.hpp b/daemon/mgmt/face-manager.hpp
index ee5115a..778e824 100644
--- a/daemon/mgmt/face-manager.hpp
+++ b/daemon/mgmt/face-manager.hpp
@@ -29,10 +29,6 @@
 #include "nfd-manager-base.hpp"
 #include "face/face-system.hpp"
 
-#include <ndn-cxx/mgmt/nfd/face-status.hpp>
-#include <ndn-cxx/mgmt/nfd/face-query-filter.hpp>
-#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
-
 namespace nfd {
 
 /**
@@ -46,67 +42,35 @@
               Dispatcher& dispatcher,
               CommandAuthenticator& authenticator);
 
-PUBLIC_WITH_TESTS_ELSE_PRIVATE: // ControlCommand
+private: // ControlCommand
   void
-  createFace(const Name& topPrefix, const Interest& interest,
+  createFace(const ControlParameters& parameters,
+             const ndn::mgmt::CommandContinuation& done);
+
+  void
+  updateFace(const Interest& interest,
              const ControlParameters& parameters,
              const ndn::mgmt::CommandContinuation& done);
 
   void
-  updateFace(const Name& topPrefix, const Interest& interest,
-             const ControlParameters& parameters,
-             const ndn::mgmt::CommandContinuation& done);
-
-  void
-  destroyFace(const Name& topPrefix, const Interest& interest,
-              const ControlParameters& parameters,
+  destroyFace(const ControlParameters& parameters,
               const ndn::mgmt::CommandContinuation& done);
 
-PUBLIC_WITH_TESTS_ELSE_PRIVATE: // helpers for ControlCommand
+private: // helpers for ControlCommand
   void
-  afterCreateFaceSuccess(const ControlParameters& parameters,
-                         const shared_ptr<Face>& newFace,
+  afterCreateFaceSuccess(const shared_ptr<Face>& face,
+                         const ControlParameters& parameters,
                          const ndn::mgmt::CommandContinuation& done);
 
+private: // StatusDataset
   void
-  afterCreateFaceFailure(uint32_t status,
-                         const std::string& reason,
-                         const ndn::mgmt::CommandContinuation& done);
-
-  static void
-  setLinkServiceOptions(Face& face, const ControlParameters& parameters);
-
-  static ControlParameters
-  collectFaceProperties(const Face& face, bool wantUris);
-
-PUBLIC_WITH_TESTS_ELSE_PRIVATE: // StatusDataset
-  void
-  listFaces(const Name& topPrefix, const Interest& interest,
-            ndn::mgmt::StatusDatasetContext& context);
+  listFaces(ndn::mgmt::StatusDatasetContext& context);
 
   void
-  listChannels(const Name& topPrefix, const Interest& interest,
-               ndn::mgmt::StatusDatasetContext& context);
+  listChannels(ndn::mgmt::StatusDatasetContext& context);
 
   void
-  queryFaces(const Name& topPrefix, const Interest& interest,
-             ndn::mgmt::StatusDatasetContext& context);
-
-private: // helpers for StatusDataset handler
-  static bool
-  matchFilter(const ndn::nfd::FaceQueryFilter& filter, const Face& face);
-
-  /** \brief get status of face, including properties and counters
-   */
-  static ndn::nfd::FaceStatus
-  collectFaceStatus(const Face& face, const time::steady_clock::TimePoint& now);
-
-  /** \brief copy face properties into traits
-   *  \tparam FaceTraits either FaceStatus or FaceEventNotification
-   */
-  template<typename FaceTraits>
-  static void
-  collectFaceProperties(const Face& face, FaceTraits& traits);
+  queryFaces(const Interest& interest, ndn::mgmt::StatusDatasetContext& context);
 
 private: // NotificationStream
   void
diff --git a/tests/daemon/mgmt/cs-manager.t.cpp b/tests/daemon/mgmt/cs-manager.t.cpp
index 18e2cdc..1a485725 100644
--- a/tests/daemon/mgmt/cs-manager.t.cpp
+++ b/tests/daemon/mgmt/cs-manager.t.cpp
@@ -24,7 +24,9 @@
  */
 
 #include "mgmt/cs-manager.hpp"
+
 #include "nfd-manager-common-fixture.hpp"
+
 #include <ndn-cxx/mgmt/nfd/cs-info.hpp>
 
 namespace nfd {
@@ -199,7 +201,7 @@
 BOOST_AUTO_TEST_CASE(Info)
 {
   m_cs.setLimit(2681);
-  for (int i = 0; i < 310; ++i) {
+  for (uint64_t i = 0; i < 310; ++i) {
     m_cs.insert(*makeData(Name("/Q8H4oi4g").appendSequenceNumber(i)));
   }
   m_cs.enableAdmit(false);
@@ -207,7 +209,7 @@
   m_fwCnt.nCsHits.set(362);
   m_fwCnt.nCsMisses.set(1493);
 
-  receiveInterest(Interest("/localhost/nfd/cs/info"));
+  receiveInterest(Interest("/localhost/nfd/cs/info").setCanBePrefix(true));
   Block dataset = concatenateResponses();
   dataset.parse();
   BOOST_REQUIRE_EQUAL(dataset.elements_size(), 1);
diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp
index d1266dd..a08c2dc 100644
--- a/tests/daemon/mgmt/face-manager.t.cpp
+++ b/tests/daemon/mgmt/face-manager.t.cpp
@@ -34,6 +34,9 @@
 #include <ndn-cxx/encoding/tlv.hpp>
 #include <ndn-cxx/encoding/tlv-nfd.hpp>
 #include <ndn-cxx/mgmt/nfd/channel-status.hpp>
+#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
+#include <ndn-cxx/mgmt/nfd/face-query-filter.hpp>
+#include <ndn-cxx/mgmt/nfd/face-status.hpp>
 #include <ndn-cxx/net/network-monitor-stub.hpp>
 
 namespace nfd {
@@ -68,18 +71,18 @@
     std::string uri = "dummy://";
     ndn::nfd::FaceScope scope = ndn::nfd::FACE_SCOPE_NON_LOCAL;
 
-    if ((flags & SET_SCOPE_LOCAL) != 0) {
+    if (flags & SET_SCOPE_LOCAL) {
       scope = ndn::nfd::FACE_SCOPE_LOCAL;
     }
-    if ((flags & SET_URI_TEST) != 0) {
+    if (flags & SET_URI_TEST) {
       uri = "test://";
     }
 
     auto face = make_shared<DummyFace>(uri, uri, scope);
     m_faceTable.add(face);
 
-    if ((flags & RANDOMIZE_COUNTERS) != 0) {
-      const face::FaceCounters& counters = face->getCounters();
+    if (flags & RANDOMIZE_COUNTERS) {
+      const auto& counters = face->getCounters();
       randomizeCounter(counters.nInInterests);
       randomizeCounter(counters.nOutInterests);
       randomizeCounter(counters.nInData);
@@ -92,8 +95,8 @@
       randomizeCounter(counters.nOutBytes);
     }
 
-    advanceClocks(time::milliseconds(1), 10); // wait for notification posted
-    if ((flags & REMOVE_LAST_NOTIFICATION) != 0) {
+    advanceClocks(1_ms, 10); // wait for notification posted
+    if (flags & REMOVE_LAST_NOTIFICATION) {
       m_responses.pop_back();
     }
 
@@ -154,12 +157,12 @@
 
 BOOST_AUTO_TEST_CASE(FaceDataset)
 {
-  const size_t nEntries = 303;
+  const size_t nEntries = 32;
   for (size_t i = 0; i < nEntries; ++i) {
     addFace(REMOVE_LAST_NOTIFICATION | SET_URI_TEST | RANDOMIZE_COUNTERS);
   }
 
-  receiveInterest(Interest("/localhost/nfd/faces/list"));
+  receiveInterest(Interest("/localhost/nfd/faces/list").setCanBePrefix(true));
 
   Block content = concatenateResponses();
   content.parse();
@@ -171,9 +174,39 @@
     BOOST_CHECK(m_faceTable.get(decodedStatus.getFaceId()) != nullptr);
     faceIds.insert(decodedStatus.getFaceId());
   }
-
   BOOST_CHECK_EQUAL(faceIds.size(), nEntries);
-  // TODO#3325 check dataset contents including counter values
+
+  ndn::nfd::FaceStatus status(content.elements().front());
+  const Face* face = m_faceTable.get(status.getFaceId());
+  BOOST_REQUIRE(face != nullptr);
+
+  // check face properties
+  BOOST_CHECK_EQUAL(status.getRemoteUri(), face->getRemoteUri().toString());
+  BOOST_CHECK_EQUAL(status.getLocalUri(), face->getLocalUri().toString());
+  BOOST_CHECK_EQUAL(status.hasExpirationPeriod(),
+                    face->getExpirationTime() != time::steady_clock::time_point::max());
+  BOOST_CHECK_EQUAL(status.getFaceScope(), face->getScope());
+  BOOST_CHECK_EQUAL(status.getFacePersistency(), face->getPersistency());
+  BOOST_CHECK_EQUAL(status.getLinkType(), face->getLinkType());
+
+  // check link service properties
+  BOOST_CHECK_EQUAL(status.hasBaseCongestionMarkingInterval(), false);
+  BOOST_CHECK_EQUAL(status.hasDefaultCongestionThreshold(), false);
+  BOOST_CHECK_EQUAL(status.getFlags(), 0);
+
+  // check transport properties
+  BOOST_CHECK_EQUAL(status.hasMtu(), true);
+  BOOST_CHECK_EQUAL(status.getMtu(), ndn::MAX_NDN_PACKET_SIZE);
+
+  // check counters
+  BOOST_CHECK_EQUAL(status.getNInInterests(), face->getCounters().nInInterests);
+  BOOST_CHECK_EQUAL(status.getNInData(), face->getCounters().nInData);
+  BOOST_CHECK_EQUAL(status.getNInNacks(), face->getCounters().nInNacks);
+  BOOST_CHECK_EQUAL(status.getNOutInterests(), face->getCounters().nOutInterests);
+  BOOST_CHECK_EQUAL(status.getNOutData(), face->getCounters().nOutData);
+  BOOST_CHECK_EQUAL(status.getNOutNacks(), face->getCounters().nOutNacks);
+  BOOST_CHECK_EQUAL(status.getNInBytes(), face->getCounters().nInBytes);
+  BOOST_CHECK_EQUAL(status.getNOutBytes(), face->getCounters().nOutBytes);
 }
 
 BOOST_AUTO_TEST_CASE(FaceQuery)
@@ -184,20 +217,22 @@
   auto face2 = addFace(REMOVE_LAST_NOTIFICATION | SET_SCOPE_LOCAL); // dummy://, local
   auto face3 = addFace(REMOVE_LAST_NOTIFICATION | SET_URI_TEST); // test://
 
-  auto generateQueryName = [] (const FaceQueryFilter& filter) {
-    return Name("/localhost/nfd/faces/query").append(filter.wireEncode());
+  auto generateQuery = [] (const FaceQueryFilter& filter) {
+    return Interest(Name("/localhost/nfd/faces/query").append(filter.wireEncode()))
+           .setCanBePrefix(true);
   };
 
-  auto querySchemeName = generateQueryName(FaceQueryFilter().setUriScheme("dummy"));
-  auto queryIdName = generateQueryName(FaceQueryFilter().setFaceId(face1->getId()));
-  auto queryScopeName = generateQueryName(FaceQueryFilter().setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL));
+  auto schemeQuery = generateQuery(FaceQueryFilter().setUriScheme("dummy"));
+  auto idQuery = generateQuery(FaceQueryFilter().setFaceId(face1->getId()));
+  auto scopeQuery = generateQuery(FaceQueryFilter().setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL));
   auto invalidQueryName = Name("/localhost/nfd/faces/query")
                           .append(ndn::makeStringBlock(tlv::Content, "invalid"));
+  auto invalidQuery = Interest(invalidQueryName).setCanBePrefix(true);
 
-  receiveInterest(Interest(querySchemeName)); // face1 and face2 expected
-  receiveInterest(Interest(queryIdName)); // face1 expected
-  receiveInterest(Interest(queryScopeName)); // face1 and face3 expected
-  receiveInterest(Interest(invalidQueryName)); // nack expected
+  receiveInterest(schemeQuery); // face1 and face2 expected
+  receiveInterest(idQuery); // face1 expected
+  receiveInterest(scopeQuery); // face1 and face3 expected
+  receiveInterest(invalidQuery); // nack expected
 
   BOOST_REQUIRE_EQUAL(m_responses.size(), 4);
 
@@ -295,18 +330,17 @@
 
 BOOST_AUTO_TEST_CASE(ChannelDataset)
 {
-  m_faceSystem.m_factories["test"] =
-    make_unique<TestProtocolFactory>(m_faceSystem.makePFCtorParams());
+  m_faceSystem.m_factories["test"] = make_unique<TestProtocolFactory>(m_faceSystem.makePFCtorParams());
   auto factory = static_cast<TestProtocolFactory*>(m_faceSystem.getFactoryById("test"));
 
-  const size_t nEntries = 404;
+  const size_t nEntries = 42;
   std::map<std::string, shared_ptr<TestChannel>> addedChannels;
   for (size_t i = 0; i < nEntries; i++) {
     auto channel = factory->addChannel("test" + to_string(i) + "://");
     addedChannels[channel->getUri().toString()] = channel;
   }
 
-  receiveInterest(Interest("/localhost/nfd/faces/channels"));
+  receiveInterest(Interest("/localhost/nfd/faces/channels").setCanBePrefix(true));
 
   Block content = concatenateResponses();
   content.parse();
@@ -353,7 +387,7 @@
 
   // trigger FACE_EVENT_DOWN notification
   dynamic_cast<face::tests::DummyTransport*>(face->getTransport())->setState(face::FaceState::DOWN);
-  advanceClocks(time::milliseconds(1), 10);
+  advanceClocks(1_ms, 10);
   BOOST_CHECK_EQUAL(face->getState(), face::FaceState::DOWN);
 
   // check notification
@@ -374,7 +408,7 @@
 
   // trigger FACE_EVENT_UP notification
   dynamic_cast<face::tests::DummyTransport*>(face->getTransport())->setState(face::FaceState::UP);
-  advanceClocks(time::milliseconds(1), 10);
+  advanceClocks(1_ms, 10);
   BOOST_CHECK_EQUAL(face->getState(), face::FaceState::UP);
 
   // check notification
@@ -403,7 +437,7 @@
   BOOST_CHECK_EQUAL(m_manager.m_faceStateChangeConn.count(faceId), 1);
 
   face->close(); // trigger FaceDestroy FACE_EVENT_DESTROYED
-  advanceClocks(time::milliseconds(1), 10);
+  advanceClocks(1_ms, 10);
 
   // check notification
   BOOST_REQUIRE_EQUAL(m_responses.size(), 2);
diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp
index e2986bc..f0a91ff 100644
--- a/tests/daemon/mgmt/fib-manager.t.cpp
+++ b/tests/daemon/mgmt/fib-manager.t.cpp
@@ -414,7 +414,7 @@
     fibEntry->addNextHop(*m_faceTable.get(addFace()), std::numeric_limits<uint8_t>::max() - 2);
   }
 
-  receiveInterest(Interest("/localhost/nfd/fib/list"));
+  receiveInterest(Interest("/localhost/nfd/fib/list").setCanBePrefix(true));
 
   Block content = concatenateResponses();
   content.parse();
diff --git a/tests/daemon/mgmt/strategy-choice-manager.t.cpp b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
index b4718a9..817966e 100644
--- a/tests/daemon/mgmt/strategy-choice-manager.t.cpp
+++ b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
@@ -28,6 +28,7 @@
 
 #include "nfd-manager-common-fixture.hpp"
 #include "../fw/dummy-strategy.hpp"
+
 #include <ndn-cxx/mgmt/nfd/strategy-choice.hpp>
 
 namespace nfd {
@@ -204,7 +205,7 @@
     expected[entry.getPrefix()] = entry.getStrategyInstanceName();
   }
 
-  for (int i = expected.size(); i < 1024; ++i) {
+  for (size_t i = expected.size(); i < 1024; ++i) {
     Name name("/SC");
     name.appendNumber(i);
     Name strategy = DummyStrategy::getStrategyName(i);
@@ -214,7 +215,8 @@
     expected[name] = strategy;
   }
 
-  receiveInterest(Interest("/localhost/nfd/strategy-choice/list"));
+  receiveInterest(Interest("/localhost/nfd/strategy-choice/list").setCanBePrefix(true));
+
   Block dataset = concatenateResponses();
   dataset.parse();
   BOOST_CHECK_EQUAL(dataset.elements_size(), expected.size());
