diff --git a/tests/test-publish-async.cpp b/tests/test-publish-async.cpp
index 270e6fc..4f4ede7 100644
--- a/tests/test-publish-async.cpp
+++ b/tests/test-publish-async.cpp
@@ -12,7 +12,6 @@
 #include <ndn-cpp/face.hpp>
 #include <ndn-cpp/security/identity/memory-identity-storage.hpp>
 #include <ndn-cpp/security/identity/memory-private-key-storage.hpp>
-#include <ndn-cpp/security/policy/no-verify-policy-manager.hpp>
 #include <ndn-cpp/security/key-chain.hpp>
 
 using namespace std;
@@ -66,8 +65,10 @@
 
 class Echo {
 public:
-  Echo(KeyChain &keyChain, const Name& certificateName)
-  : keyChain_(keyChain), certificateName_(certificateName), responseCount_(0)
+  Echo(KeyChain &keyChain, Face &face)
+    : keyChain_(keyChain)
+    , face_(face)
+    , responseCount_(0)
   { 
   }
   
@@ -81,13 +82,17 @@
     // Make and sign a Data packet.
     Data data(interest->getName());
     string content(string("Echo ") + interest->getName().toUri());
+    data.setFreshnessPeriod(1000);
     data.setContent((const uint8_t *)&content[0], content.size());
-    data.getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
-    keyChain_.sign(data, certificateName_);
-    Blob encodedData = data.wireEncode();
 
-    cout << "Sent content " << content << endl;
-    transport.send(*encodedData);
+    keyChain_.sign(data);
+
+    // Put data on wire
+    face_.put(data);
+
+    // Unregister prefix to ensure that the processing thread finishes after Data
+    // packet is send out to the forwarder
+    face_.unsetInterestFilter(registeredPrefixId);
   }
   
   // onRegisterFailed.
@@ -97,42 +102,39 @@
     cout << "Register failed for prefix " << prefix->toUri() << endl;
   }
 
-  KeyChain keyChain_;
-  Name certificateName_;
+  KeyChain &keyChain_;
+  Face &face_;
   int responseCount_;
 };
 
 int main(int argc, char** argv)
 {
   try {
-    Face face("localhost");
+    Face face;
         
     ptr_lib::shared_ptr<MemoryIdentityStorage> identityStorage(new MemoryIdentityStorage());
     ptr_lib::shared_ptr<MemoryPrivateKeyStorage> privateKeyStorage(new MemoryPrivateKeyStorage());
-    KeyChain keyChain
-      (ptr_lib::make_shared<IdentityManager>(identityStorage, privateKeyStorage), ptr_lib::shared_ptr<NoVerifyPolicyManager>(new NoVerifyPolicyManager()));
-    keyChain.setFace(&face);
-    
+    KeyChain keyChain(identityStorage, privateKeyStorage);
+
+    Name keyName("/testname/dsk-123");
+
     // Initialize the storage.
-    Name keyName("/testname/DSK-123");
-    Name certificateName = keyName.getSubName(0, keyName.size() - 1).append("KEY").append
-           (keyName.get(keyName.size() - 1)).append("ID-CERT").append("0");
-    identityStorage->addKey(keyName, KEY_TYPE_RSA, Blob(DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER)));
-    privateKeyStorage->setKeyPairForKeyName
-      (keyName, DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER), DEFAULT_PRIVATE_KEY_DER, sizeof(DEFAULT_PRIVATE_KEY_DER));
+    identityStorage->addKey(keyName, KEY_TYPE_RSA,
+                            PublicKey(DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER)));
+
+    privateKeyStorage->setKeyPairForKeyName(keyName,
+                                            DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER),
+                                            DEFAULT_PRIVATE_KEY_DER, sizeof(DEFAULT_PRIVATE_KEY_DER));
+
+    keyChain.identities().addCertificateAsDefault(*keyChain.identities().selfSign(keyName));
+    
    
-    Echo echo(keyChain, certificateName);
+    Echo echo(keyChain, face);
     Name prefix("/testecho");
     cout << "Register prefix  " << prefix.toUri() << endl;
     face.setInterestFilter(prefix, func_lib::ref(echo), func_lib::ref(echo));
     
-    // The main event loop.  
-    // Wait forever to receive one interest for the prefix.
-    while (echo.responseCount_ < 1) {
-      face.processEvents();
-      // We need to sleep for a few milliseconds so we don't use 100% of the CPU.
-      usleep(10000);
-    }
+    face.processEvents();
   } catch (std::exception& e) {
     cout << "exception: " << e.what() << endl;
   }
