fix all test failures

Change-Id: Iead2d25adc95ad1d7d2252a854dc8ba854c90889
diff --git a/tests/database-fixture.hpp b/tests/database-fixture.hpp
index 4223c98..06c63f5 100644
--- a/tests/database-fixture.hpp
+++ b/tests/database-fixture.hpp
@@ -40,10 +40,7 @@
 public:
   DatabaseFixture()
   {
-    auto parentDir = boost::filesystem::path(getenv("TEST_HOME"));
-    if (!boost::filesystem::exists(parentDir)) {
-      boost::filesystem::create_directory(parentDir);
-    }
+    auto parentDir = boost::filesystem::path(getenv("HOME"));
     dbDir = parentDir / ".ndncert";
     if (!boost::filesystem::exists(dbDir)) {
       boost::filesystem::create_directory(dbDir);
diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index 46b56ef..f21b06d 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -36,7 +36,7 @@
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
   ca.setProbeHandler([&](const Block& probeInfo) {
     return "example";
@@ -87,7 +87,7 @@
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 40cb3d6..cb3cfcd 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -34,7 +34,7 @@
 
 BOOST_AUTO_TEST_CASE(Initialization)
 {
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
   BOOST_CHECK_EQUAL(ca.getCaConf().m_caPrefix, "/ndn");
 
@@ -55,7 +55,7 @@
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
   ca.setProbeHandler([&](const Block& probeInfo) {
     return "example";
@@ -96,7 +96,7 @@
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
   ca.setProbeHandler([&](const Block& probeInfo) {
     return "example";
@@ -130,7 +130,7 @@
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
@@ -168,7 +168,7 @@
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
@@ -218,7 +218,7 @@
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test");
   advanceClocks(time::milliseconds(20), 60);
 
@@ -251,7 +251,7 @@
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
   ca.m_config.m_probe = "email";
   advanceClocks(time::milliseconds(20), 60);
@@ -286,7 +286,7 @@
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  util::DummyClientFace face(io, {true, true});
+  util::DummyClientFace face(io, m_keyChain, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
diff --git a/tests/unit-tests/challenge-credential.t.cpp b/tests/unit-tests/challenge-credential.t.cpp
index 566ffd8..2b8e9b2 100644
--- a/tests/unit-tests/challenge-credential.t.cpp
+++ b/tests/unit-tests/challenge-credential.t.cpp
@@ -70,7 +70,6 @@
   selfSigned.setContent(makeStringBlock(tlv::Content, "123"));
   m_keyChain.sign(selfSigned, signingByCertificate(trustAnchor));
 
-  // generate SELECT interest
   std::stringstream ss;
   io::save<security::v2::Certificate>(selfSigned, ss);
   auto checkCert = *(io::load<security::v2::Certificate>(ss));
@@ -89,10 +88,12 @@
   ss.clear();
 
   Block params = makeEmptyBlock(tlv_encrypted_payload);
-  params.push_back(makeStringBlock(tlv_parameter_key, ChallengeCredential::JSON_CREDENTIAL_SELF));
-  params.push_back(makeStringBlock(tlv_parameter_value, selfSignedStr));
+  params.push_back(makeStringBlock(tlv_selected_challenge, "Credential"));
   params.push_back(makeStringBlock(tlv_parameter_key, ChallengeCredential::JSON_CREDENTIAL_CERT));
   params.push_back(makeStringBlock(tlv_parameter_value, credentialStr));
+  params.push_back(makeStringBlock(tlv_parameter_key, ChallengeCredential::JSON_CREDENTIAL_SELF));
+  params.push_back(makeStringBlock(tlv_parameter_value, selfSignedStr));
+  params.encode();
 
   challenge.handleChallengeRequest(params, request);
   BOOST_CHECK_EQUAL(request.m_status, STATUS_PENDING);