tests: Fix failure of NameServer and Validator test suites

The fix makes sure that DummyFace::receive does not called from within
signal invocation.

Change-Id: Idc6d2866ece585932687c0bafe7731a6fa66ddea
diff --git a/tests/unit/daemon/name-server.cpp b/tests/unit/daemon/name-server.cpp
index 0e5f302..f2b64bb 100644
--- a/tests/unit/daemon/name-server.cpp
+++ b/tests/unit/daemon/name-server.cpp
@@ -311,9 +311,14 @@
   {
     // ensure prefix is registered
     run();
-    validatorFace->onSendInterest.connect([&] (const Interest& interest) {
+
+    validatorFace->onSendInterest.connect([this] (const Interest& interest) {
       NDNS_LOG_TRACE("validatorFace get Interest: " << interest.getName());
-      face->receive(interest);
+
+      shared_ptr<const Interest> i = interest.shared_from_this();
+      io.post([i, this] {
+          face->receive(*i);
+        });
     });
   }
 
@@ -386,9 +391,12 @@
   bool hasDataBack = false;
 
   shared_ptr<Regex> regex = make_shared<Regex>("(<>*)<KEY>(<>+)<ID-CERT><>");
-  face->onSendData.connectSingleShot([&] (const Data& data) {
+  face->onSendData.connect([&] (const Data& data) {
     if (regex->match(data.getName())) {
-      validatorFace->receive(data); // It's data requested by validator
+      shared_ptr<const Data> d = data.shared_from_this();
+      io.post([d, this] {
+          validatorFace->receive(*d); // It's data requested by validator
+        });
     }
     else {
       // cert is requested by validator