build: switch to C++17

Change-Id: Ia147b22fbdee68d87f0289851683ffbbb4466caa
diff --git a/.jenkins.d/00-deps.sh b/.jenkins.d/00-deps.sh
index 95dfe37..a287116 100755
--- a/.jenkins.d/00-deps.sh
+++ b/.jenkins.d/00-deps.sh
@@ -35,7 +35,7 @@
     case $JOB_NAME in
         *code-coverage)
             sudo apt-get -qy install lcov python3-pip
-            pip3 install --user --upgrade --upgrade-strategy=eager 'gcovr~=5.0'
+            pip3 install --user --upgrade --upgrade-strategy=eager 'gcovr~=5.1'
             ;;
         *Docs)
             sudo apt-get -qy install doxygen graphviz python3-pip
diff --git a/.jenkins.d/30-coverage.sh b/.jenkins.d/30-coverage.sh
index 6a6db85..5d74ff8 100755
--- a/.jenkins.d/30-coverage.sh
+++ b/.jenkins.d/30-coverage.sh
@@ -4,14 +4,13 @@
 if [[ $JOB_NAME == *"code-coverage" ]]; then
     # Generate an XML report (Cobertura format) and a detailed HTML report using gcovr
     # Note: trailing slashes are important in the paths below. Do not remove them!
-    gcovr -j$WAF_JOBS \
-          --object-directory build \
+    gcovr --object-directory build \
           --filter src/ \
           --exclude-throw-branches \
           --exclude-unreachable-branches \
-          --print-summary \
+          --cobertura build/coverage.xml \
           --html-details build/gcovr/ \
-          --xml build/coverage.xml
+          --print-summary
 
     # Generate a detailed HTML report using lcov
     lcov --quiet \
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index f086c17..7c6d282 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -136,7 +136,7 @@
     """
     def getGeneralFlags(self, conf):
         flags = super(GccBasicFlags, self).getGeneralFlags(conf)
-        flags['CXXFLAGS'] += ['-std=c++14']
+        flags['CXXFLAGS'] += ['-std=c++17']
         if Utils.unversioned_sys_platform() == 'linux':
             flags['LINKFLAGS'] += ['-fuse-ld=gold']
         elif Utils.unversioned_sys_platform() == 'freebsd':
diff --git a/README.md b/README.md
index 6766a64..106face 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 
 [![CI](https://github.com/named-data/ndns/actions/workflows/ci.yml/badge.svg)](https://github.com/named-data/ndns/actions/workflows/ci.yml)
 [![Docs](https://github.com/named-data/ndns/actions/workflows/docs.yml/badge.svg)](https://github.com/named-data/ndns/actions/workflows/docs.yml)
-![Language](https://img.shields.io/badge/C%2B%2B-14-blue)
+![Language](https://img.shields.io/badge/C%2B%2B-17-blue)
 
 **NDNS** is a completely distributed database system that largely mimics the structure of
 the DNS system in today's Internet but operates within the NDN architecture. Although the
diff --git a/src/clients/response.cpp b/src/clients/response.cpp
index 48b8a7d..4aedf73 100644
--- a/src/clients/response.cpp
+++ b/src/clients/response.cpp
@@ -163,14 +163,14 @@
 Response&
 Response::addRr(const Block& rr)
 {
-  this->m_rrs.push_back(rr);
+  m_rrs.push_back(rr);
   return *this;
 }
 
 Response&
 Response::addRr(const std::string& rr)
 {
-  return this->addRr(makeBinaryBlock(ndns::tlv::RrData, rr.c_str(), rr.size()));
+  return addRr(makeStringBlock(ndns::tlv::RrData, rr));
 }
 
 bool
diff --git a/src/clients/response.hpp b/src/clients/response.hpp
index 4e8f335..5417c8c 100644
--- a/src/clients/response.hpp
+++ b/src/clients/response.hpp
@@ -33,8 +33,7 @@
 /**
  * @brief Default life time of resource record
  */
-const time::seconds DEFAULT_RR_FRESHNESS_PERIOD = 3600_s;
-
+inline constexpr time::seconds DEFAULT_RR_FRESHNESS_PERIOD = 3600_s;
 
 /**
  * @brief NDNS Response abstraction. Response is used on client side,
diff --git a/src/daemon/config-file.hpp b/src/daemon/config-file.hpp
index b17dfe6..29a0587 100644
--- a/src/daemon/config-file.hpp
+++ b/src/daemon/config-file.hpp
@@ -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,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -107,7 +107,7 @@
   static T
   parseNumber(const ConfigSection& node, const std::string& key, const std::string& sectionName)
   {
-    static_assert(std::is_arithmetic<T>::value, "T must be an arithmetic type");
+    static_assert(std::is_arithmetic_v<T>, "T must be an arithmetic type");
 
     boost::optional<T> value = node.get_value_optional<T>();
     if (value) {
diff --git a/src/daemon/db-mgr.cpp b/src/daemon/db-mgr.cpp
index e1ab0fc..3c20f94 100644
--- a/src/daemon/db-mgr.cpp
+++ b/src/daemon/db-mgr.cpp
@@ -27,7 +27,7 @@
 
 NDNS_LOG_INIT(DbMgr);
 
-static const std::string NDNS_SCHEMA = R"SQL(
+const std::string NDNS_SCHEMA = R"SQL(
 CREATE TABLE IF NOT EXISTS zones (
   id    INTEGER NOT NULL PRIMARY KEY,
   name  BLOB NOT NULL UNIQUE,
@@ -143,20 +143,19 @@
 DbMgr::restoreName(sqlite3_stmt* stmt, int iCol)
 {
   Name name;
+  span buffer(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, iCol)),
+              sqlite3_column_bytes(stmt, iCol));
 
-  const uint8_t* buffer = static_cast<const uint8_t*>(sqlite3_column_blob(stmt, iCol));
-  size_t nBytesLeft = sqlite3_column_bytes(stmt, iCol);
-
-  while (nBytesLeft > 0) {
-    bool hasDecodingSucceeded;
+  while (!buffer.empty()) {
     name::Component component;
-    std::tie(hasDecodingSucceeded, component) = Block::fromBuffer({buffer, nBytesLeft});
-    if (!hasDecodingSucceeded) {
-      NDN_THROW(Error("Error while decoding name from the database"));
+    try {
+      component.wireDecode(Block(buffer));
+    }
+    catch (const ndn::tlv::Error&) {
+      NDN_THROW_NESTED(Error("Error while decoding name from the database"));
     }
     name.append(component);
-    buffer += component.size();
-    nBytesLeft -= component.size();
+    buffer = buffer.subspan(component.size());
   }
 
   return name;
@@ -250,8 +249,8 @@
 
   while (sqlite3_step(stmt) == SQLITE_ROW) {
     const char* key = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
-    rtn[string(key)] = Block(make_span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 1)),
-                                       sqlite3_column_bytes(stmt, 1)));
+    rtn[string(key)] = Block(span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 1)),
+                                  sqlite3_column_bytes(stmt, 1)));
   }
 
   sqlite3_finalize(stmt);
@@ -410,10 +409,10 @@
   if (sqlite3_step(stmt) == SQLITE_ROW) {
     rrset.setId(sqlite3_column_int64(stmt, 0));
     rrset.setTtl(time::seconds(sqlite3_column_int64(stmt, 1)));
-    rrset.setVersion(Block(make_span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 2)),
-                                     sqlite3_column_bytes(stmt, 2))));
-    rrset.setData(Block(make_span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 3)),
-                                  sqlite3_column_bytes(stmt, 3))));
+    rrset.setVersion(name::Component(Block(span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 2)),
+                                                sqlite3_column_bytes(stmt, 2)))));
+    rrset.setData(Block(span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 3)),
+                             sqlite3_column_bytes(stmt, 3))));
   }
   else {
     rrset.setId(0);
@@ -454,10 +453,10 @@
   if (sqlite3_step(stmt) == SQLITE_ROW) {
     rrset.setId(sqlite3_column_int64(stmt, 0));
     rrset.setTtl(time::seconds(sqlite3_column_int64(stmt, 1)));
-    rrset.setVersion(Block(make_span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 2)),
-                                     sqlite3_column_bytes(stmt, 2))));
-    rrset.setData(Block(make_span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 3)),
-                                  sqlite3_column_bytes(stmt, 3))));
+    rrset.setVersion(name::Component(Block(span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 2)),
+                                                sqlite3_column_bytes(stmt, 2)))));
+    rrset.setData(Block(span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 3)),
+                             sqlite3_column_bytes(stmt, 3))));
   }
   else {
     rrset.setId(0);
@@ -493,13 +492,13 @@
 
     rrset.setId(sqlite3_column_int64(stmt, 0));
     rrset.setTtl(time::seconds(sqlite3_column_int64(stmt, 1)));
-    rrset.setVersion(Block(make_span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 2)),
-                                     sqlite3_column_bytes(stmt, 2))));
-    rrset.setData(Block(make_span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 3)),
-                                  sqlite3_column_bytes(stmt, 3))));
+    rrset.setVersion(name::Component(Block(span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 2)),
+                                                sqlite3_column_bytes(stmt, 2)))));
+    rrset.setData(Block(span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 3)),
+                             sqlite3_column_bytes(stmt, 3))));
     rrset.setLabel(restoreName(stmt, 4));
-    rrset.setType(Block(make_span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 5)),
-                                  sqlite3_column_bytes(stmt, 5))));
+    rrset.setType(name::Component(Block(span(static_cast<const uint8_t*>(sqlite3_column_blob(stmt, 5)),
+                                             sqlite3_column_bytes(stmt, 5)))));
   }
   sqlite3_finalize(stmt);
 
diff --git a/src/daemon/db-mgr.hpp b/src/daemon/db-mgr.hpp
index 81ae5ad..747060f 100644
--- a/src/daemon/db-mgr.hpp
+++ b/src/daemon/db-mgr.hpp
@@ -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.
@@ -196,8 +196,7 @@
    * @brief remove all records of a specific type in a zone
    */
   void
-  removeRrsetsOfZoneByType(Zone& zone,
-                           const name::Component& type);
+  removeRrsetsOfZoneByType(Zone& zone, const name::Component& type);
 
   /**
    * @brief replace ttl, version, and Data with new values
@@ -220,10 +219,10 @@
    * If @p name is not preserved until @p stmt is executed, @p isStatic must be
    * set to `false`.
    */
-  void
+  static void
   saveName(const Name& name, sqlite3_stmt* stmt, int iCol, bool isStatic = true);
 
-  Name
+  static Name
   restoreName(sqlite3_stmt* stmt, int iCol);
 
 private:
diff --git a/src/daemon/rrset-factory.cpp b/src/daemon/rrset-factory.cpp
index eed7ad0..41e93a1 100644
--- a/src/daemon/rrset-factory.cpp
+++ b/src/daemon/rrset-factory.cpp
@@ -98,7 +98,7 @@
 
   rrset.setVersion(name.get(-1));
 
-  return std::make_pair(rrset, name);
+  return {rrset, name};
 }
 
 bool
@@ -125,13 +125,10 @@
   if (ttl == DEFAULT_RR_TTL)
     ttl = m_zone.getTtl();
 
-  std::pair<Rrset, Name> rrsetAndName = generateBaseRrset(label, label::NS_RR_TYPE, version, ttl);
-  const Name& name = rrsetAndName.second;
-  Rrset& rrset = rrsetAndName.first;
+  auto [rrset, name] = generateBaseRrset(label, label::NS_RR_TYPE, version, ttl);
 
   Link link(name);
   link.setDelegationList(std::move(delegations));
-
   setContentType(link, NDNS_LINK, ttl);
   sign(link);
   rrset.setData(link.wireEncode());
@@ -152,19 +149,16 @@
   if (ttl == DEFAULT_RR_TTL)
     ttl = m_zone.getTtl();
 
-  Name name;
-  Rrset rrset;
-  std::tie(rrset, name) = generateBaseRrset(label, label::TXT_RR_TYPE, version, ttl);
+  auto [rrset, name] = generateBaseRrset(label, label::TXT_RR_TYPE, version, ttl);
 
   std::vector<Block> rrs;
   rrs.reserve(strings.size());
   for (const auto& item : strings) {
-    rrs.push_back(makeBinaryBlock(ndns::tlv::RrData, item.data(), item.size()));
+    rrs.push_back(makeStringBlock(ndns::tlv::RrData, item));
   }
 
   Data data(name);
   data.setContent(wireEncode(rrs));
-
   setContentType(data, NDNS_RESP, ttl);
   sign(data);
   rrset.setData(data.wireEncode());
@@ -185,13 +179,10 @@
   if (ttl == DEFAULT_RR_TTL)
     ttl = m_zone.getTtl();
 
-  Name name;
-  Rrset rrset;
-  std::tie(rrset, name) = generateBaseRrset(label, label::APPCERT_RR_TYPE, version, ttl);
+  auto [rrset, name] = generateBaseRrset(label, label::APPCERT_RR_TYPE, version, ttl);
 
   Data data(name);
   data.setContent(cert.wireEncode());
-
   setContentType(data, NDNS_KEY, ttl);
   sign(data);
   rrset.setData(data.wireEncode());
@@ -211,12 +202,9 @@
   if (ttl == DEFAULT_RR_TTL)
     ttl = m_zone.getTtl();
 
-  Name name;
-  Rrset rrset;
-  std::tie(rrset, name) = generateBaseRrset(label, label::NS_RR_TYPE, version, ttl);
+  auto [rrset, name] = generateBaseRrset(label, label::NS_RR_TYPE, version, ttl);
 
   Data data(name);
-
   setContentType(data, NDNS_AUTH, ttl);
   sign(data);
   rrset.setData(data.wireEncode());
@@ -238,9 +226,7 @@
   if (ttl == DEFAULT_RR_TTL)
     ttl = m_zone.getTtl();
 
-  Name name;
-  Rrset rrset;
-  std::tie(rrset, name) = generateBaseRrset(label, label::DOE_RR_TYPE, version, ttl);
+  auto [rrset, name] = generateBaseRrset(label, label::DOE_RR_TYPE, version, ttl);
 
   std::vector<Block> range;
   range.push_back(lowerLabel.wireEncode());
@@ -303,12 +289,9 @@
 {
   std::vector<std::string> txts;
   wire.parse();
-
   for (const auto& e : wire.elements()) {
-    txts.push_back(std::string(reinterpret_cast<const char*>(e.value()),
-                               e.value_size()));
+    txts.emplace_back(reinterpret_cast<const char*>(e.value()), e.value_size());
   }
-
   return txts;
 }
 
diff --git a/src/mgmt/management-tool.cpp b/src/mgmt/management-tool.cpp
index 9ac88cf..33b704c 100644
--- a/src/mgmt/management-tool.cpp
+++ b/src/mgmt/management-tool.cpp
@@ -38,7 +38,6 @@
 #include <ndn-cxx/security/signing-helpers.hpp>
 #include <ndn-cxx/security/transform.hpp>
 
-
 namespace ndn {
 namespace ndns {
 
@@ -48,8 +47,6 @@
 using security::transform::streamSink;
 using security::transform::bufferSource;
 using security::Certificate;
-using security::Identity;
-using security::Key;
 
 ManagementTool::ManagementTool(const std::string& dbFile, KeyChain& keyChain)
   : m_keyChain(keyChain)
@@ -112,14 +109,14 @@
   NDNS_LOG_INFO("Generated D-Key's identityName: " + dkeyIdentityName.toUri());
 
   Name dskName;
-  Key ksk;
-  Key dsk;
-  Key dkey;
+  security::Key ksk;
+  security::Key dsk;
+  security::Key dkey;
   Certificate dskCert;
   Certificate kskCert;
   Certificate dkeyCert;
-  Identity zoneIdentity = m_keyChain.createIdentity(zoneIdentityName);
-  Identity dkeyIdentity = m_keyChain.createIdentity(dkeyIdentityName);
+  auto zoneIdentity = m_keyChain.createIdentity(zoneIdentityName);
+  auto dkeyIdentity = m_keyChain.createIdentity(dkeyIdentityName);
 
   if (dkeyCertName == DEFAULT_CERT) {
     dkey = m_keyChain.createKey(dkeyIdentity);
@@ -319,7 +316,7 @@
                                  const std::string& inFile,
                                  const time::seconds& ttl,
                                  const Name& inputDskCertName,
-                                 const ndn::io::IoEncoding encoding,
+                                 ndn::io::IoEncoding encoding,
                                  bool needResign)
 {
   //check precondition
@@ -397,7 +394,7 @@
 }
 
 void
-ManagementTool::listZone(const Name& zoneName, std::ostream& os, const bool printRaw)
+ManagementTool::listZone(const Name& zoneName, std::ostream& os, bool printRaw)
 {
   Zone zone(zoneName);
   if (!m_dbMgr.find(zone)) {
@@ -440,7 +437,7 @@
                     || re.getContentType() == NDNS_KEY
                     || re.getContentType() == NDNS_AUTH ? 1 : re.getRrs().size();
 
-    const std::vector<Block>& rrs = re.getRrs();
+    const auto& rrs = re.getRrs();
 
     if (re.getContentType() != NDNS_BLOB && re.getContentType() != NDNS_KEY) {
       os << "; rrset=" << rrset.getLabel().toUri()
@@ -515,7 +512,8 @@
 }
 
 void
-ManagementTool::listAllZones(std::ostream& os) {
+ManagementTool::listAllZones(std::ostream& os)
+{
   std::vector<Zone> zones = m_dbMgr.listZones();
 
   size_t nameWidth = 0;
@@ -622,8 +620,8 @@
 bool
 ManagementTool::matchCertificate(const Name& certName, const Name& identity)
 {
-  security::Identity id = m_keyChain.getPib().getIdentity(identity);
-  for (const security::Key& key : id.getKeys()) {
+  auto id = m_keyChain.getPib().getIdentity(identity);
+  for (const auto& key : id.getKeys()) {
     try {
       key.getCertificate(certName);
       return true;
diff --git a/src/mgmt/management-tool.hpp b/src/mgmt/management-tool.hpp
index ba00458..592205c 100644
--- a/src/mgmt/management-tool.hpp
+++ b/src/mgmt/management-tool.hpp
@@ -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.
@@ -35,14 +35,14 @@
 namespace ndn {
 namespace ndns {
 
-static const Name DEFAULT_CERT;
-static const Name ROOT_ZONE;
-static const time::seconds DEFAULT_CACHE_TTL = time::seconds(3600);
-static const time::seconds DEFAULT_CERT_TTL = time::days(365);
-static const std::vector<std::string> DEFAULT_CONTENTS;
-static const std::string DEFAULT_IO = "-";
-static const time::seconds DEFAULT_RR_TTL = time::seconds(0);
-static constexpr uint64_t VERSION_USE_UNIX_TIMESTAMP = std::numeric_limits<uint64_t>::max();
+inline const Name DEFAULT_CERT;
+inline const Name ROOT_ZONE;
+inline constexpr time::seconds DEFAULT_CACHE_TTL = time::seconds(3600);
+inline constexpr time::seconds DEFAULT_CERT_TTL = time::days(365);
+inline const std::vector<std::string> DEFAULT_CONTENTS;
+inline const std::string DEFAULT_IO = "-";
+inline constexpr time::seconds DEFAULT_RR_TTL = time::seconds(0);
+inline constexpr uint64_t VERSION_USE_UNIX_TIMESTAMP = std::numeric_limits<uint64_t>::max();
 
 /**
  * @brief provides management tools to the NDNS system, such as zone creation, zone delegation, DSK
@@ -139,7 +139,7 @@
                    const std::string& inFile = DEFAULT_IO,
                    const time::seconds& ttl = DEFAULT_RR_TTL,
                    const Name& dskCertName = DEFAULT_CERT,
-                   const ndn::io::IoEncoding encoding = ndn::io::BASE64,
+                   ndn::io::IoEncoding encoding = ndn::io::BASE64,
                    bool needResign = false);
 
   /** @brief Add rrset to the NDNS local database
@@ -211,7 +211,7 @@
    *  @throw Error if zoneName does not exist in the database
    */
   void
-  listZone(const Name& zoneName, std::ostream& os, const bool printRaw = false);
+  listZone(const Name& zoneName, std::ostream& os, bool printRaw = false);
 
   /** @brief lists all existing zones within this name server.
    *
diff --git a/tests/unit/clients/response.t.cpp b/tests/unit/clients/response.t.cpp
index 97a6fe0..a24505e 100644
--- a/tests/unit/clients/response.t.cpp
+++ b/tests/unit/clients/response.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.
@@ -33,7 +33,6 @@
   Name zone("/net");
   name::Component qType = ndns::label::NDNS_ITERATIVE_QUERY;
 
-
   ndns::Response r(zone, qType);
   r.setRrLabel(Name("/ndnsim/www"));
   r.setRrType(label::CERT_RR_TYPE);
@@ -47,7 +46,7 @@
   BOOST_CHECK_EQUAL(r.getQueryType(), qType);
 
   const std::string DATA1("some fake content");
-  r.setAppContent(makeBinaryBlock(ndn::tlv::Content, DATA1.c_str(), DATA1.size()));
+  r.setAppContent(makeStringBlock(ndn::tlv::Content, DATA1));
 
   //const Block& block = r.wireEncode();
   shared_ptr<Data> data = r.toData();
@@ -63,10 +62,9 @@
   r4.setContentType(NDNS_RESP);
 
   std::string str = "Just try it";
-  Block s = makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size());
+  Block s = makeStringBlock(ndns::tlv::RrData, str);
   r4.addRr(s);
   str = "Go to Hell";
-  // Block s2 = makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size());
   r4.addRr(str);
 
   BOOST_CHECK_NE(r2, r4);
@@ -78,7 +76,7 @@
 
   BOOST_CHECK_EQUAL(r5.fromData(zone, *data), true);
   BOOST_CHECK_EQUAL(r4, r5);
- }
+}
 
 BOOST_AUTO_TEST_SUITE_END()
 
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);
   }
diff --git a/tests/unit/database-test-data.cpp b/tests/unit/database-test-data.cpp
index 9188eff..f77c5be 100644
--- a/tests/unit/database-test-data.cpp
+++ b/tests/unit/database-test-data.cpp
@@ -30,8 +30,6 @@
 namespace ndns {
 namespace tests {
 
-NDNS_LOG_INIT(TestFakeData);
-
 const fs::path DbTestData::TEST_DATABASE = fs::path(UNIT_TESTS_TMPDIR) / "test-ndns.db";
 const Name DbTestData::TEST_IDENTITY_NAME("/test19");
 const fs::path DbTestData::TEST_CERT = fs::path(UNIT_TESTS_TMPDIR) / "anchors" / "root.cert";
@@ -44,13 +42,11 @@
 }
 
 DbTestData::DbTestData()
-  : m_session(TEST_DATABASE.string()),
-    m_testName("/test19"),
-    m_netName("/test19/net"),
-    m_ndnsimName("/test19/net/ndnsim")
+  : m_session(TEST_DATABASE.string())
+  , m_testName("/test19")
+  , m_netName("/test19/net")
+  , m_ndnsimName("/test19/net/ndnsim")
 {
-  NDNS_LOG_TRACE("start creating test data");
-
   NdnsValidatorBuilder::VALIDATOR_CONF_FILE = (fs::path(UNIT_TESTS_TMPDIR) / "validator.conf").string();
 
   ManagementTool tool(TEST_DATABASE.string(), m_keyChain);
@@ -81,18 +77,15 @@
   m_identity = CertHelper::getIdentity(m_keyChain, identityName);
   m_certName = CertHelper::getDefaultCertificateNameOfIdentity(m_keyChain, identityName);
   m_cert = CertHelper::getCertificate(m_keyChain, identityName, m_certName);
+  BOOST_ASSERT(!m_certName.empty());
 
   io::save(m_cert, TEST_CERT.string());
-  NDNS_LOG_INFO("save test root cert " << m_certName << " to: " << TEST_CERT.string());
-
-  BOOST_ASSERT(!m_certName.empty());
-  NDNS_LOG_TRACE("test certName: " << m_certName);
 
   int certificateIndex = 0;
   auto addQueryRrset = [this, &certificateIndex] (const Name& label, Zone& zone,
                                                   const name::Component& type) {
     const time::seconds ttl(3000 + 100 * certificateIndex);
-    const name::Component version = name::Component::fromVersion(100 + 1000 * certificateIndex);
+    const auto version = name::Component::fromVersion(100 + 1000 * certificateIndex);
     name::Component qType(label::NDNS_ITERATIVE_QUERY);
     NdnsContentType contentType = NDNS_RESP;
     if (type == label::APPCERT_RR_TYPE) {
@@ -122,8 +115,6 @@
   // last link is the same as former one
   BOOST_ASSERT(!m_links.empty());
   m_links.push_back(m_links.back());
-
-  NDNS_LOG_INFO("insert testing data: OK");
 }
 
 void
diff --git a/tests/unit/mgmt/management-tool.t.cpp b/tests/unit/mgmt/management-tool.t.cpp
index 97282d1..d4f6234 100644
--- a/tests/unit/mgmt/management-tool.t.cpp
+++ b/tests/unit/mgmt/management-tool.t.cpp
@@ -447,8 +447,7 @@
 
   // Check certificate freshnessPeriod and validity
   Certificate cert = CertHelper::getCertificate(m_keyChain, zoneIdentityName, dsk);
-  time::system_clock::TimePoint beg,end;
-  std::tie(beg, end) = cert.getValidityPeriod().getPeriod();
+  auto [beg, end] = cert.getValidityPeriod().getPeriod();
 
   BOOST_REQUIRE_NO_THROW(cert = findCertFromDb(zone, dsk));
   BOOST_CHECK_EQUAL(cert.getFreshnessPeriod(), time::seconds(4200));
diff --git a/tools/ndns-update.cpp b/tools/ndns-update.cpp
index 4ad2c60..5bdf6fb 100644
--- a/tools/ndns-update.cpp
+++ b/tools/ndns-update.cpp
@@ -87,13 +87,12 @@
   onData(const Interest&, const Data& data)
   {
     NDNS_LOG_INFO("get response of Update");
-    int ret = -1;
-    std::string msg;
-    std::tie(ret, msg) = parseResponse(data);
-    NDNS_LOG_INFO("Return Code: " << ret << ", and Update "
-                  << (ret == UPDATE_OK ? "succeeds" : "fails"));
-    if (ret != UPDATE_OK)
+    auto [ret, msg] = parseResponse(data);
+    NDNS_LOG_INFO("Return Code: " << ret << ", and Update " << (ret == UPDATE_OK ? "succeeds" : "fails"));
+
+    if (ret != UPDATE_OK) {
       m_hasError = true;
+    }
 
     if (!msg.empty()) {
       NDNS_LOG_INFO("Return Msg: " << msg);
@@ -120,11 +119,11 @@
         ret = readNonNegativeInteger(*val);
       }
       else if (val->type() == ndns::tlv::UpdateReturnMsg) {
-        msg =  std::string(reinterpret_cast<const char*>(val->value()), val->value_size());
+        msg = std::string(reinterpret_cast<const char*>(val->value()), val->value_size());
       }
     }
 
-    return std::make_tuple(ret, msg);
+    return {ret, msg};
   }
 
   /**
@@ -319,8 +318,7 @@
       re.setContentType(contentType);
 
       for (const auto& content : contents) {
-        re.addRr(makeBinaryBlock(ndns::tlv::RrData, content.c_str(), content.size()));
-
+        re.addRr(makeStringBlock(ndns::tlv::RrData, content));
         // re.addRr(content);
       }