diff --git a/tests/unit/daemon/db-mgr.t.cpp b/tests/unit/daemon/db-mgr.t.cpp
index 0b69330..a30f2dc 100644
--- a/tests/unit/daemon/db-mgr.t.cpp
+++ b/tests/unit/daemon/db-mgr.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020, Regents of the University of California.
+ * Copyright (c) 2014-2022, Regents of the University of California.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -18,7 +18,6 @@
  */
 
 #include "daemon/db-mgr.hpp"
-#include "logger.hpp"
 
 #include "boost-test.hpp"
 
@@ -29,8 +28,6 @@
 namespace ndns {
 namespace tests {
 
-NDNS_LOG_INIT(DbMgrTest);
-
 BOOST_AUTO_TEST_SUITE(DbMgr)
 
 const auto TEST_DATABASE2 = boost::filesystem::path(UNIT_TESTS_TMPDIR) / "test-ndns.db";
@@ -46,7 +43,6 @@
   ~DbMgrFixture()
   {
     session.close();
-    NDNS_LOG_INFO("remove database " << TEST_DATABASE2);
     boost::filesystem::remove(TEST_DATABASE2);
   }
 
@@ -113,7 +109,7 @@
   rrset1.setTtl(time::seconds(4600));
 
   static const std::string DATA1 = "SOME DATA";
-  rrset1.setData(makeBinaryBlock(ndn::tlv::Content, DATA1.c_str(), DATA1.size()));
+  rrset1.setData(makeStringBlock(ndn::tlv::Content, DATA1));
 
   BOOST_CHECK_EQUAL(rrset1.getId(), 0);
   BOOST_CHECK_NO_THROW(session.insert(rrset1));
@@ -141,7 +137,7 @@
 
   rrset1.setVersion(name::Component::fromVersion(890));
   static const std::string DATA2 = "ANOTHER DATA";
-  rrset1.setData(makeBinaryBlock(ndn::tlv::Content, DATA2.c_str(), DATA2.size()));
+  rrset1.setData(makeStringBlock(ndn::tlv::Content, DATA2));
 
   BOOST_CHECK_NO_THROW(session.update(rrset1));
 
@@ -190,7 +186,7 @@
   rrset1.setId(1);
   BOOST_CHECK_NO_THROW(session.remove(rrset1));
 
-  rrset1.setZone(0);
+  rrset1.setZone(nullptr);
   rrset1.setId(1);
   BOOST_CHECK_NO_THROW(session.remove(rrset1));
 }
@@ -233,7 +229,7 @@
   rrset1.setTtl(time::seconds(4600));
 
   static const std::string DATA1 = "SOME DATA";
-  rrset1.setData(makeBinaryBlock(ndn::tlv::Content, DATA1.data(), DATA1.size()));
+  rrset1.setData(makeStringBlock(ndn::tlv::Content, DATA1));
   session.insert(rrset1);
 
   Rrset rrset2(&zone);
@@ -242,14 +238,13 @@
   rrset2.setVersion(name::Component::fromVersion(232));
   rrset2.setTtl(time::seconds(2100));
   std::string data2 = "host1.net";
-  rrset2.setData(makeBinaryBlock(ndn::tlv::Content, data2.c_str(), data2.size()));
+  rrset2.setData(makeStringBlock(ndn::tlv::Content, data2));
   session.insert(rrset2);
 
   std::vector<Rrset> vec = session.findRrsets(zone);
   BOOST_CHECK_EQUAL(vec.size(), 2);
 
-  std::sort(vec.begin(),
-            vec.end(),
+  std::sort(vec.begin(), vec.end(),
             [] (const Rrset& n1, const Rrset& n2) {
               return n1.getLabel().size() < n2.getLabel().size();
             });
diff --git a/tests/unit/daemon/name-server.t.cpp b/tests/unit/daemon/name-server.t.cpp
index a0ec0f5..35555dd 100644
--- a/tests/unit/daemon/name-server.t.cpp
+++ b/tests/unit/daemon/name-server.t.cpp
@@ -22,7 +22,6 @@
 #include "clients/query.hpp"
 #include "clients/response.hpp"
 #include "daemon/db-mgr.hpp"
-#include "logger.hpp"
 
 #include "boost-test.hpp"
 #include "unit/database-test-data.hpp"
@@ -34,8 +33,6 @@
 namespace ndns {
 namespace tests {
 
-NDNS_LOG_INIT(NameServerTest);
-
 class NameServerFixture : public DbTestData
 {
 public:
@@ -76,7 +73,6 @@
 
   face.onSendData.connectSingleShot([&] (const Data& data) {
     hasDataBack = true;
-    NDNS_LOG_TRACE("get Data back");
     BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
 
     Response resp;
@@ -101,7 +97,6 @@
   // will ask for non-existing record
   face.onSendData.connectSingleShot([&] (const Data& data) {
     ++nDataBack;
-    NDNS_LOG_TRACE("get Data back");
     BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
 
     Response resp;
@@ -115,7 +110,6 @@
   // will ask for the existing record (will have type NDNS_KEY, as it is certificate)
   face.onSendData.connectSingleShot([&] (const Data& data) {
     ++nDataBack;
-    NDNS_LOG_TRACE("get Data back");
     BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
 
     Response resp;
@@ -173,9 +167,9 @@
   re.setContentType(NDNS_RESP);
 
   std::string str = "ns1.ndnsim.net";
-  re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
+  re.addRr(makeStringBlock(ndns::tlv::RrData, str));
   str = "ns2.ndnsim.net";
-  re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
+  re.addRr(makeStringBlock(ndns::tlv::RrData, str));
 
   auto data = re.toData();
   m_keyChain.sign(*data, security::signingByCertificate(m_cert));
@@ -191,18 +185,17 @@
 
   face.onSendData.connectSingleShot([&] (const Data& data) {
     hasDataBack = true;
-    NDNS_LOG_TRACE("get Data back");
     BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
     Response resp;
 
     BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
     BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_RESP); // by default NDNS_BLOB is enough
-    BOOST_CHECK_GT(resp.getRrs().size(), 0);
+    BOOST_TEST_REQUIRE(resp.getRrs().size() > 0);
     Block block = resp.getRrs()[0];
     block.parse();
     int ret = -1;
     BOOST_CHECK_EQUAL(block.type(), ndns::tlv::RrData);
-    Block::element_const_iterator val = block.elements_begin();
+    auto val = block.elements_begin();
     BOOST_CHECK_EQUAL(val->type(), ndns::tlv::UpdateReturnCode); // the first must be return code
     ret = readNonNegativeInteger(*val);
     BOOST_CHECK_EQUAL(ret, 0);
@@ -223,9 +216,9 @@
   re.setContentType(NDNS_RESP);
 
   std::string str = "ns1.ndnsim.net";
-  re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
+  re.addRr(makeStringBlock(ndns::tlv::RrData, str));
   str = "ns2.ndnsim.net";
-  re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
+  re.addRr(makeStringBlock(ndns::tlv::RrData, str));
 
   auto data = re.toData();
   m_keyChain.sign(*data, security::signingByCertificate(m_cert));
@@ -241,18 +234,17 @@
 
   face.onSendData.connectSingleShot([&] (const Data& data) {
     hasDataBack = true;
-    NDNS_LOG_TRACE("get Data back");
     BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
     Response resp;
 
     BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
     BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_RESP); // by default NDNS_BLOB is enough
-    BOOST_CHECK_GT(resp.getRrs().size(), 0);
+    BOOST_TEST_REQUIRE(resp.getRrs().size() > 0);
     Block block = resp.getRrs()[0];
     block.parse();
     int ret = -1;
     BOOST_CHECK_EQUAL(block.type(), ndns::tlv::RrData);
-    Block::element_const_iterator val = block.elements_begin();
+    auto val = block.elements_begin();
     BOOST_CHECK_EQUAL(val->type(), ndns::tlv::UpdateReturnCode); // the first must be return code
     ret = readNonNegativeInteger(*val);
     BOOST_CHECK_EQUAL(ret, 0);
@@ -284,9 +276,8 @@
 
   m_keyChain.sign(dskCert, security::signingByCertificate(m_cert));
   m_keyChain.setDefaultCertificate(dsk, dskCert);
-
-  NDNS_LOG_TRACE("KeyChain: add cert: " << dskCert.getName() << ". KeyLocator: "
-                 << dskCert.getKeyLocator()->getName());
+  BOOST_TEST_MESSAGE("Added Certificate=" << dskCert.getName()
+                     << " KeyLocator=" << dskCert.getKeyLocator()->getName());
 
   Rrset rrset(&m_test);
   Name label = dskCert.getName().getPrefix(-2).getSubName(m_test.getName().size() + 1);
@@ -296,8 +287,7 @@
   rrset.setTtl(m_test.getTtl());
   rrset.setData(dskCert.wireEncode());
   m_session.insert(rrset);
-  NDNS_LOG_TRACE("DB: zone " << m_test << " add a CERT RR with name="
-                 << dskCert.getName() << " rrLabel=" << label);
+  BOOST_TEST_MESSAGE(m_test << " added CERT RR with name=" << dskCert.getName() << " label=" << label);
 
   Response re;
   re.setZone(zone);
@@ -307,9 +297,9 @@
   re.setContentType(NDNS_RESP);
 
   std::string str = "ns1.ndnsim.net";
-  re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
+  re.addRr(makeStringBlock(ndns::tlv::RrData, str));
   str = "ns2.ndnsim.net";
-  re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
+  re.addRr(makeStringBlock(ndns::tlv::RrData, str));
 
   auto data = re.toData();
   m_keyChain.sign(*data, security::signingByCertificate(dskCert));
@@ -326,7 +316,7 @@
   // no data back, since the Update cannot pass verification
   face.onSendData.connectSingleShot([&] (const Data&) {
     hasDataBack = true;
-    BOOST_FAIL("UNEXPECTED");
+    BOOST_ERROR("unexpected onSendData");
   });
 
   face.receive(q.toInterest());
@@ -349,9 +339,8 @@
     run();
 
     validatorFace.onSendInterest.connect([this] (const Interest& interest) {
-      NDNS_LOG_TRACE("validatorFace get Interest: " << interest.getName());
-      auto i = interest.shared_from_this();
-      io.post([i, this] { face.receive(*i); });
+      BOOST_TEST_MESSAGE("Interest on validatorFace: " << interest);
+      io.post([this, i = interest.shared_from_this()] { face.receive(*i); });
     });
   }
 
@@ -381,9 +370,9 @@
   re.setContentType(NDNS_RESP);
 
   std::string str = "ns1.ndnsim.net";
-  re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
+  re.addRr(makeStringBlock(ndns::tlv::RrData, str));
   str = "ns2.ndnsim.net";
-  re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
+  re.addRr(makeStringBlock(ndns::tlv::RrData, str));
 
   auto data = re.toData();
   m_keyChain.sign(*data, security::signingByCertificate(m_cert));
@@ -396,25 +385,23 @@
   q.setRrType(label::NDNS_UPDATE_LABEL);
 
   bool hasDataBack = false;
+  auto regex = make_shared<Regex>("(<>*)<NDNS><KEY>(<>+)<CERT><>");
 
-  shared_ptr<Regex> regex = make_shared<Regex>("(<>*)<NDNS><KEY>(<>+)<CERT><>");
   face.onSendData.connect([&] (const Data& data) {
     if (regex->match(data.getName())) {
-      shared_ptr<const Data> d = data.shared_from_this();
-      io.post([d, this] {
-          validatorFace.receive(*d); // It's data requested by validator
-        });
+      io.post([this, d = data.shared_from_this()] {
+        validatorFace.receive(*d); // It's data requested by validator
+      });
     }
     else {
       // cert is requested by validator
       hasDataBack = true;
-      NDNS_LOG_TRACE("get Data back");
       BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
       Response resp;
 
       BOOST_CHECK_NO_THROW(resp.fromData(zone, data));
       BOOST_CHECK_EQUAL(resp.getContentType(), NDNS_RESP); // by default NDNS_BLOB is enough
-      BOOST_CHECK_GT(resp.getRrs().size(), 0);
+      BOOST_TEST_REQUIRE(resp.getRrs().size() > 0);
       Block block = resp.getRrs()[0];
       block.parse();
       int ret = -1;
diff --git a/tests/unit/daemon/rrset-factory.t.cpp b/tests/unit/daemon/rrset-factory.t.cpp
index 5314dad..66c65dd 100644
--- a/tests/unit/daemon/rrset-factory.t.cpp
+++ b/tests/unit/daemon/rrset-factory.t.cpp
@@ -31,8 +31,6 @@
 namespace ndns {
 namespace tests {
 
-NDNS_LOG_INIT(RrsetFactoryTest);
-
 const auto TEST_DATABASE2 = boost::filesystem::path(UNIT_TESTS_TMPDIR) / "test-ndns.db";
 const auto TEST_CERT = boost::filesystem::path(UNIT_TESTS_TMPDIR) / "anchors" / "root.cert";
 
@@ -47,24 +45,18 @@
     Zone zone1;
     zone1.setName(m_zoneName);
     zone1.setTtl(time::seconds(4600));
-    BOOST_CHECK_NO_THROW(m_session.insert(zone1));
+    m_session.insert(zone1);
 
     Name identityName = Name(TEST_IDENTITY_NAME).append("NDNS");
-
     m_identity = m_keyChain.createIdentity(identityName);
     m_cert = m_identity.getDefaultKey().getDefaultCertificate();
     m_certName = m_cert.getName();
     saveIdentityCert(m_identity, TEST_CERT.string());
-
-    NDNS_LOG_INFO("save test root cert " << m_certName << " to: " << TEST_CERT);
-    BOOST_CHECK_GT(m_certName.size(), 0);
-    NDNS_LOG_TRACE("test certName: " << m_certName);
   }
 
   ~RrsetFactoryFixture()
   {
     m_session.close();
-    NDNS_LOG_INFO("remove database " << TEST_DATABASE2);
     boost::filesystem::remove(TEST_DATABASE2);
     boost::filesystem::remove(TEST_CERT);
   }
