diff --git a/tests/communication/test-sync-logic-handler.cpp b/tests/communication/test-sync-logic-handler.cpp
index 55007b8..3c71f74 100644
--- a/tests/communication/test-sync-logic-handler.cpp
+++ b/tests/communication/test-sync-logic-handler.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2021,  The University of Memphis,
+ * Copyright (c) 2014-2022,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -36,13 +36,7 @@
 {
 public:
   SyncLogicFixture()
-    : face(m_ioService, m_keyChain)
-    , conf(face, m_keyChain)
-    , confProcessor(conf, SYNC_PROTOCOL_PSYNC)
-    , testIsLsaNew([] (const ndn::Name& name, const Lsa::Type& lsaType,
-                       const uint64_t sequenceNumber) {
-                     return true;
-                   })
+    : testIsLsaNew([] (auto&&...) { return true; })
     , sync(face, testIsLsaNew, conf)
     , updateNamePrefix(this->conf.getLsaPrefix().toUri() +
                        this->conf.getSiteName().toUri() +
@@ -65,146 +59,156 @@
   }
 
 public:
-  ndn::util::DummyClientFace face;
-  ConfParameter conf;
-  DummyConfFileProcessor confProcessor;
+  ndn::util::DummyClientFace face{m_ioService, m_keyChain};
+  ConfParameter conf{face, m_keyChain};
+  DummyConfFileProcessor confProcessor{conf, SYNC_PROTOCOL_PSYNC};
   SyncLogicHandler::IsLsaNew testIsLsaNew;
   SyncLogicHandler sync;
 
   const std::string updateNamePrefix;
-  const std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY,
-                                             Lsa::Type::COORDINATE};
+  const std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME,
+                                           Lsa::Type::ADJACENCY,
+                                           Lsa::Type::COORDINATE};
 };
 
-BOOST_AUTO_TEST_SUITE(TestSyncLogicHandler)
+BOOST_FIXTURE_TEST_SUITE(TestSyncLogicHandler, SyncLogicFixture)
 
 /* Tests that when SyncLogicHandler receives an LSA of either Name or
    Adjacency type that appears to be newer, it will emit to its signal
    with those LSA details.
  */
-BOOST_FIXTURE_TEST_CASE(UpdateForOtherLS, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(UpdateForOtherLS)
 {
-  std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::ADJACENCY};
-
+  size_t nCallbacks = 0;
   uint64_t syncSeqNo = 1;
 
-  for (const Lsa::Type& lsaType : lsaTypes) {
+  for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::ADJACENCY}) {
     std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
 
-    // Actual testing done here -- signal function callback
     ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
-      [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
-           const ndn::Name& originRouter) {
+      [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
         BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
         BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
+        ++nCallbacks;
       });
 
     this->receiveUpdate(updateName, syncSeqNo);
   }
+
+  BOOST_CHECK_EQUAL(nCallbacks, 2);
 }
 
 /* Tests that when SyncLogicHandler in HR mode receives an LSA of
    either Coordinate or Name type that appears to be newer, it will
    emit to its signal with those LSA details.
  */
-BOOST_FIXTURE_TEST_CASE(UpdateForOtherHR, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(UpdateForOtherHR)
 {
   this->conf.setHyperbolicState(HYPERBOLIC_STATE_ON);
 
+  size_t nCallbacks = 0;
   uint64_t syncSeqNo = 1;
-  std::vector<Lsa::Type> lsaTypes = {Lsa::Type::NAME, Lsa::Type::COORDINATE};
 
-  for (const Lsa::Type& lsaType : lsaTypes) {
+  for (auto lsaType : {Lsa::Type::NAME, Lsa::Type::COORDINATE}) {
     std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
 
     ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
-      [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
-           const ndn::Name& originRouter) {
+      [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
         BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
         BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
+        ++nCallbacks;
       });
 
     this->receiveUpdate(updateName, syncSeqNo);
   }
+
+  BOOST_CHECK_EQUAL(nCallbacks, 2);
 }
 
 /* Tests that when SyncLogicHandler in HR-dry mode receives an LSA of
    any type that appears to be newer, it will emit to its signal with
    those LSA details.
  */
-BOOST_FIXTURE_TEST_CASE(UpdateForOtherHRDry, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(UpdateForOtherHRDry)
 {
   this->conf.setHyperbolicState(HYPERBOLIC_STATE_DRY_RUN);
 
+  size_t nCallbacks = 0;
   uint64_t syncSeqNo = 1;
 
-  for (const Lsa::Type& lsaType : this->lsaTypes) {
+  for (auto lsaType : this->lsaTypes) {
     std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(lsaType);
 
     ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
-      [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
-           const ndn::Name& originRouter) {
+      [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
         BOOST_CHECK_EQUAL(ndn::Name{updateName}, routerName);
         BOOST_CHECK_EQUAL(sequenceNumber, syncSeqNo);
+        ++nCallbacks;
       });
 
     this->receiveUpdate(updateName, syncSeqNo);
   }
+
+  BOOST_CHECK_EQUAL(nCallbacks, 3);
 }
 
 /* Tests that when SyncLogicHandler receives an update for an LSA with
    details matching this router's details, it will *not* emit to its
    signal those LSA details.
  */
-BOOST_FIXTURE_TEST_CASE(NoUpdateForSelf, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(NoUpdateForSelf)
 {
   const uint64_t sequenceNumber = 1;
 
-  for (const Lsa::Type& lsaType : this->lsaTypes) {
+  for (auto lsaType : this->lsaTypes) {
     // To ensure that we get correctly-separated components, create
     // and modify a Name to hand off.
-    ndn::Name updateName = ndn::Name{this->conf.getLsaPrefix()};
+    ndn::Name updateName{this->conf.getLsaPrefix()};
     updateName.append(this->conf.getSiteName())
               .append(this->conf.getRouterName())
               .append(boost::lexical_cast<std::string>(lsaType));
 
     ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
-      [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
-           const ndn::Name& originRouter) {
+      [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
         BOOST_FAIL("Updates for self should not be emitted!");
       });
 
     this->receiveUpdate(updateName.toUri(), sequenceNumber);
   }
+
+  // avoid "test case [...] did not check any assertions" message from Boost.Test
+  BOOST_CHECK(true);
 }
 
 /* Tests that when SyncLogicHandler receives an update for an LSA with
    details that do not match the expected format, it will *not* emit
    to its signal those LSA details.
  */
-BOOST_FIXTURE_TEST_CASE(MalformedUpdate, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(MalformedUpdate)
 {
   const uint64_t sequenceNumber = 1;
 
-  for (const Lsa::Type& lsaType : this->lsaTypes) {
+  for (auto lsaType : this->lsaTypes) {
     ndn::Name updateName{this->conf.getSiteName()};
     updateName.append(this->conf.getRouterName()).append(boost::lexical_cast<std::string>(lsaType));
 
     ndn::util::signal::ScopedConnection connection = this->sync.onNewLsa->connect(
-      [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
-           const ndn::Name& originRouter) {
+      [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
         BOOST_FAIL("Malformed updates should not be emitted!");
       });
 
     this->receiveUpdate(updateName.toUri(), sequenceNumber);
   }
+
+  // avoid "test case [...] did not check any assertions" message from Boost.Test
+  BOOST_CHECK(true);
 }
 
 /* Tests that when SyncLogicHandler receives an update for an LSA with
    details that do not appear to be new, it will *not* emit to its
    signal those LSA details.
  */
-BOOST_FIXTURE_TEST_CASE(LsaNotNew, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(LsaNotNew)
 {
   auto testLsaAlwaysFalse = [] (const ndn::Name& routerName, const Lsa::Type& lsaType,
                                 const uint64_t& sequenceNumber) {
@@ -214,21 +218,22 @@
   const uint64_t sequenceNumber = 1;
   SyncLogicHandler sync{this->face, testLsaAlwaysFalse, this->conf};
     ndn::util::signal::ScopedConnection connection = sync.onNewLsa->connect(
-      [&] (const ndn::Name& routerName, const uint64_t& sequenceNumber,
-           const ndn::Name& originRouter) {
+      [&] (const auto& routerName, uint64_t sequenceNumber, const auto& originRouter) {
         BOOST_FAIL("An update for an LSA with non-new sequence number should not emit!");
       });
 
   std::string updateName = this->updateNamePrefix + boost::lexical_cast<std::string>(Lsa::Type::NAME);
-
   this->receiveUpdate(updateName, sequenceNumber);
+
+  // avoid "test case [...] did not check any assertions" message from Boost.Test
+  BOOST_CHECK(true);
 }
 
 /* Tests that SyncLogicHandler successfully concatenates configured
    variables together to form the necessary prefixes to advertise
    through sync.
  */
-BOOST_FIXTURE_TEST_CASE(UpdatePrefix, SyncLogicFixture)
+BOOST_AUTO_TEST_CASE(UpdatePrefix)
 {
   ndn::Name expectedPrefix = this->conf.getLsaPrefix();
   expectedPrefix.append(this->conf.getSiteName());
