diff --git a/tests/chunks/discover-version.t.cpp b/tests/chunks/discover-version.t.cpp
index eb94f1d..9c3a844 100644
--- a/tests/chunks/discover-version.t.cpp
+++ b/tests/chunks/discover-version.t.cpp
@@ -44,50 +44,63 @@
   void
   run(const Name& prefix)
   {
-    BOOST_REQUIRE(!prefix.empty());
-
     discover = make_unique<DiscoverVersion>(face, prefix, opt);
     discover->onDiscoverySuccess.connect([this] (const Name& versionedName) {
-      BOOST_REQUIRE(!versionedName.empty() && versionedName[-1].isVersion());
-      discoveredVersion = versionedName[-1].toVersion();
       isDiscoveryFinished = true;
+      discoveredName = versionedName;
+      if (!versionedName.empty() && versionedName[-1].isVersion())
+        discoveredVersion = versionedName[-1].toVersion();
     });
     discover->onDiscoveryFailure.connect([this] (const std::string&) {
       isDiscoveryFinished = true;
     });
 
     discover->run();
-    advanceClocks(io, time::nanoseconds(1));
+    advanceClocks(io, 1_ns);
   }
 
 protected:
+  const Name name = "/ndn/chunks/test";
+  const uint64_t version = 1449227841747;
   boost::asio::io_service io;
   util::DummyClientFace face{io};
-  Name name = "/ndn/chunks/test";
   Options opt;
   unique_ptr<DiscoverVersion> discover;
+  optional<Name> discoveredName;
   optional<uint64_t> discoveredVersion;
   bool isDiscoveryFinished = false;
-  uint64_t version = 1449227841747;
 };
 
 BOOST_AUTO_TEST_SUITE(Chunks)
 BOOST_FIXTURE_TEST_SUITE(TestDiscoverVersion, DiscoverVersionFixture)
 
-BOOST_AUTO_TEST_CASE(VersionNumberIsProvided)
+BOOST_AUTO_TEST_CASE(Disabled)
 {
-  run(Name(name).appendVersion(version));
+  opt.disableVersionDiscovery = true;
+  run(name);
 
-  // no version discovery interest is expressed
+  // no version discovery Interest is expressed
   BOOST_CHECK_EQUAL(face.sentInterests.size(), 0);
 
-  BOOST_CHECK_EQUAL(isDiscoveryFinished, true);
+  BOOST_CHECK_EQUAL(discoveredName.value(), name);
+  BOOST_CHECK_EQUAL(discoveredVersion.has_value(), false);
+}
+
+BOOST_AUTO_TEST_CASE(NameWithVersion)
+{
+  // start with a name that already contains a version component
+  Name versionedName = Name(name).appendVersion(version);
+  run(versionedName);
+
+  // no version discovery Interest is expressed
+  BOOST_CHECK_EQUAL(face.sentInterests.size(), 0);
+
+  BOOST_CHECK_EQUAL(discoveredName.value(), versionedName);
   BOOST_CHECK_EQUAL(discoveredVersion.value(), version);
 }
 
-BOOST_AUTO_TEST_CASE(DiscoverySuccess)
+BOOST_AUTO_TEST_CASE(Success)
 {
-  // express a discovery Interest to learn Data version
   run(name);
 
   BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -96,61 +109,66 @@
   auto lastInterest = face.sentInterests.back();
   BOOST_CHECK_EQUAL(lastInterest.getName(), discoveryInterest.getName());
 
-  // Send back a metadata packet with a valid versioned name
+  // send back a metadata packet with a valid versioned name
   MetadataObject mobject;
   mobject.setVersionedName(Name(name).appendVersion(version));
   face.receive(mobject.makeData(lastInterest.getName(), m_keyChain));
-  advanceClocks(io, time::nanoseconds(1));
+  advanceClocks(io, 1_ns);
 
-  BOOST_CHECK(isDiscoveryFinished);
   BOOST_CHECK_EQUAL(discoveredVersion.value(), version);
 }
 
 BOOST_AUTO_TEST_CASE(InvalidDiscoveredVersionedName)
 {
-  // issue a discovery Interest to learn Data version
   run(name);
 
   BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
 
-  // Send back a metadata packet with an invalid versioned name
+  // send back a metadata packet with an invalid versioned name
   MetadataObject mobject;
   mobject.setVersionedName(name);
   face.receive(mobject.makeData(face.sentInterests.back().getName(), m_keyChain));
 
   // finish discovery process without a resolved version number
-  BOOST_CHECK(isDiscoveryFinished);
-  BOOST_CHECK(!discoveredVersion.has_value());
+  BOOST_CHECK_EQUAL(isDiscoveryFinished, true);
+  BOOST_CHECK_EQUAL(discoveredName.has_value(), false);
+  BOOST_CHECK_EQUAL(discoveredVersion.has_value(), false);
 }
 
 BOOST_AUTO_TEST_CASE(InvalidMetadataPacket)
 {
-  // issue a discovery Interest to learn Data version
   run(name);
 
   BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
 
-  // Send back an invalid metadata packet
+  // send back an invalid metadata packet
   Data data(face.sentInterests.back().getName());
   data.setFreshnessPeriod(1_s);
   data.setContentType(tlv::ContentType_Key);
   face.receive(signData(data));
 
   // finish discovery process without a resolved version number
-  BOOST_CHECK(isDiscoveryFinished);
-  BOOST_CHECK(!discoveredVersion.has_value());
+  BOOST_CHECK_EQUAL(isDiscoveryFinished, true);
+  BOOST_CHECK_EQUAL(discoveredName.has_value(), false);
+  BOOST_CHECK_EQUAL(discoveredVersion.has_value(), false);
 }
 
-BOOST_AUTO_TEST_CASE(Timeout1)
+BOOST_AUTO_TEST_CASE(MaxRetriesExceeded)
 {
-  // issue a discovery Interest to learn Data version
+  opt.maxRetriesOnTimeoutOrNack = 3;
   run(name);
 
   BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
 
-  // timeout discovery Interests
-  for (int retries = 0; retries < opt.maxRetriesOnTimeoutOrNack; ++retries) {
-    advanceClocks(io, opt.interestLifetime);
+  // timeout or nack discovery Interests
+  for (int retries = 0; retries < opt.maxRetriesOnTimeoutOrNack * 2; ++retries) {
+    if (retries % 2 == 0) {
+      advanceClocks(io, opt.interestLifetime);
+    }
+    else {
+      face.receive(makeNack(face.sentInterests.back(), lp::NackReason::DUPLICATE));
+      advanceClocks(io, 1_ns);
+    }
 
     BOOST_CHECK_EQUAL(isDiscoveryFinished, false);
     BOOST_REQUIRE_EQUAL(face.sentInterests.size(), retries + 2);
@@ -160,20 +178,27 @@
   advanceClocks(io, opt.interestLifetime);
 
   // finish discovery process without a resolved version number
-  BOOST_CHECK(isDiscoveryFinished);
-  BOOST_CHECK(!discoveredVersion.has_value());
+  BOOST_CHECK_EQUAL(isDiscoveryFinished, true);
+  BOOST_CHECK_EQUAL(discoveredName.has_value(), false);
+  BOOST_CHECK_EQUAL(discoveredVersion.has_value(), false);
 }
 
-BOOST_AUTO_TEST_CASE(Timeout2)
+BOOST_AUTO_TEST_CASE(SuccessAfterNackAndTimeout)
 {
-  // issue a discovery Interest to learn Data version
+  opt.maxRetriesOnTimeoutOrNack = 3;
   run(name);
 
   BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
 
-  // timeout discovery Interests
-  for (int retries = 0; retries < opt.maxRetriesOnTimeoutOrNack; ++retries) {
-    advanceClocks(io, opt.interestLifetime);
+  // timeout or nack discovery Interests
+  for (int retries = 0; retries < opt.maxRetriesOnTimeoutOrNack * 2; ++retries) {
+    if (retries % 2 == 0) {
+      advanceClocks(io, opt.interestLifetime);
+    }
+    else {
+      face.receive(makeNack(face.sentInterests.back(), lp::NackReason::DUPLICATE));
+      advanceClocks(io, 1_ns);
+    }
 
     BOOST_CHECK_EQUAL(isDiscoveryFinished, false);
     BOOST_REQUIRE_EQUAL(face.sentInterests.size(), retries + 2);
@@ -183,9 +208,8 @@
   MetadataObject mobject;
   mobject.setVersionedName(Name(name).appendVersion(version));
   face.receive(mobject.makeData(face.sentInterests.back().getName(), m_keyChain));
-  advanceClocks(io, time::nanoseconds(1));
+  advanceClocks(io, 1_ns);
 
-  BOOST_CHECK(isDiscoveryFinished);
   BOOST_CHECK_EQUAL(discoveredVersion.value(), version);
 }
 
