diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index 28850a8..09986c6 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -19,9 +19,9 @@
  */
 
 #include "ca-module.hpp"
-#include "requester.hpp"
 #include "challenge-modules/challenge-pin.hpp"
 #include "protocol-detail/info.hpp"
+#include "requester.hpp"
 #include "test-common.hpp"
 
 namespace ndn {
@@ -38,12 +38,26 @@
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
+  auto metaData = ca.generateCaConfigMetaData();
+  auto profileData = ca.generateCaConfigData();
   advanceClocks(time::milliseconds(20), 60);
 
   Interest interest = MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
   std::cout << "CA Config discovery Interest Size: " << interest.wireEncode().size() << std::endl;
   shared_ptr<Interest> infoInterest = nullptr;
 
+  face.setInterestFilter(InterestFilter("/ndn/CA/INFO"),
+                         [&](const auto&, const Interest& interest) {
+                           if (interest.matchesData(*metaData)) {
+                             face.put(*metaData);
+                           }
+                           else {
+                             BOOST_CHECK(interest.matchesData(*profileData));
+                             face.put(*profileData);
+                           }
+                         }, nullptr, nullptr);
+  advanceClocks(time::milliseconds(20), 60);
+
   int count = 0;
   face.onSendData.connect([&](const Data& response) {
     if (count == 0) {
@@ -55,7 +69,6 @@
       interest.setCanBePrefix(true);
       infoInterest = make_shared<Interest>(interest);
       std::cout << "CA Config fetch Interest Size: " << infoInterest->wireEncode().size() << std::endl;
-
     }
     else {
       count++;
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 7abb727..774484d 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -39,11 +39,11 @@
   BOOST_CHECK_EQUAL(ca.getCaConf().m_caItem.m_caPrefix, "/ndn");
 
   advanceClocks(time::milliseconds(20), 60);
-  BOOST_CHECK_EQUAL(ca.m_registeredPrefixHandles.size(), 2);
-  BOOST_CHECK_EQUAL(ca.m_interestFilterHandles.size(), 5);  // onInfo, onProbe, onNew, onChallenge, onRevoke
+  BOOST_CHECK_EQUAL(ca.m_registeredPrefixHandles.size(), 1); // removed local discovery registration
+  BOOST_CHECK_EQUAL(ca.m_interestFilterHandles.size(), 4);  // onProbe, onNew, onChallenge, onRevoke
 }
 
-BOOST_AUTO_TEST_CASE(HandleInfo)
+BOOST_AUTO_TEST_CASE(HandleProfileFetching)
 {
   auto identity = addIdentity(Name("/ndn"));
   auto key = identity.getDefaultKey();
@@ -51,27 +51,53 @@
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
+  auto metaData = ca.generateCaConfigMetaData();
+  auto profileData = ca.generateCaConfigData();
   advanceClocks(time::milliseconds(20), 60);
 
-  Interest interest("/ndn/CA/INFO");
-  interest.setCanBePrefix(false);
+  Interest interest = MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
+  shared_ptr<Interest> infoInterest = nullptr;
+
+  face.setInterestFilter(InterestFilter("/ndn/CA/INFO"),
+                         [&](const auto&, const Interest& interest) {
+                           if (interest.matchesData(*metaData)) {
+                             face.put(*metaData);
+                           }
+                           else {
+                             BOOST_CHECK(interest.matchesData(*profileData));
+                             face.put(*profileData);
+                           }
+                         }, nullptr, nullptr);
+  advanceClocks(time::milliseconds(20), 60);
 
   int count = 0;
   face.onSendData.connect([&](const Data& response) {
-    count++;
-    BOOST_CHECK(security::verifySignature(response, cert));
-    auto contentBlock = response.getContent();
-    contentBlock.parse();
-    auto caItem = INFO::decodeDataContent(contentBlock);
-    BOOST_CHECK_EQUAL(caItem.m_caPrefix, "/ndn");
-    BOOST_CHECK_EQUAL(caItem.m_probeParameterKeys.size(), 1);
-    BOOST_CHECK_EQUAL(caItem.m_cert->wireEncode(), cert.wireEncode());
-    BOOST_CHECK_EQUAL(caItem.m_caInfo, "ndn testbed ca");
+    if (count == 0) {
+      count++;
+      auto block = response.getContent();
+      block.parse();
+      Interest interest(Name(block.get(tlv::Name)));
+      interest.setCanBePrefix(true);
+      infoInterest = make_shared<Interest>(interest);
+    }
+    else {
+      count++;
+      BOOST_CHECK(security::verifySignature(response, cert));
+      auto contentBlock = response.getContent();
+      contentBlock.parse();
+      auto caItem = INFO::decodeDataContent(contentBlock);
+      BOOST_CHECK_EQUAL(caItem.m_caPrefix, "/ndn");
+      BOOST_CHECK_EQUAL(caItem.m_probeParameterKeys.size(), 1);
+      BOOST_CHECK_EQUAL(caItem.m_probeParameterKeys.front(), "full name");
+      BOOST_CHECK_EQUAL(caItem.m_cert->wireEncode(), cert.wireEncode());
+      BOOST_CHECK_EQUAL(caItem.m_caInfo, "ndn testbed ca");
+    }
   });
   face.receive(interest);
-
   advanceClocks(time::milliseconds(20), 60);
-  BOOST_CHECK_EQUAL(count, 1);
+  face.receive(*infoInterest);
+  advanceClocks(time::milliseconds(20), 60);
+  BOOST_CHECK_EQUAL(count, 2);
 }
 
 BOOST_AUTO_TEST_CASE(HandleProbe)
