diff --git a/tests/main.cpp b/tests/main.cpp
index 7d606e7..ac55966 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -23,12 +23,13 @@
 #include <boost/test/unit_test.hpp>
 
 #include "logger.hpp"
+#include "config.hpp"
 
 namespace ndn {
 namespace ndns {
 namespace tests {
 
-class UnitTestsLogging
+class UnitTestsLogging : boost::noncopyable
 {
 public:
   UnitTestsLogging()
diff --git a/tests/unit/daemon/db-mgr.cpp b/tests/unit/daemon/db-mgr.cpp
new file mode 100644
index 0000000..fb621d2
--- /dev/null
+++ b/tests/unit/daemon/db-mgr.cpp
@@ -0,0 +1,221 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, Regents of the University of California.
+ *
+ * This file is part of NDNS (Named Data Networking Domain Name Service).
+ * See AUTHORS.md for complete list of NDNS authors and contributors.
+ *
+ * NDNS is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.hpp"
+#include "daemon/db-mgr.hpp"
+#include "logger.hpp"
+
+#include "../../boost-test.hpp"
+#include <boost/filesystem.hpp>
+
+#include <algorithm>    // std::sort
+
+namespace ndn {
+namespace ndns {
+namespace tests {
+
+NDNS_LOG_INIT("DbMgrTest")
+
+BOOST_AUTO_TEST_SUITE(DbMgr)
+
+static const boost::filesystem::path TEST_DATABASE2 = TEST_CONFIG_PATH "/" "test-ndns.db";
+
+class DbMgrFixture
+{
+public:
+  DbMgrFixture()
+    : session(TEST_DATABASE2.string())
+  {
+  }
+
+  ~DbMgrFixture()
+  {
+    session.close();
+    boost::filesystem::remove(TEST_DATABASE2);
+    NDNS_LOG_INFO("remove database " << TEST_DATABASE2);
+  }
+
+public:
+  ndns::DbMgr session;
+};
+
+
+
+BOOST_FIXTURE_TEST_CASE(Zones, DbMgrFixture)
+{
+  Zone zone1;
+  zone1.setName("/net");
+  zone1.setTtl(time::seconds(4600));
+  BOOST_CHECK_NO_THROW(session.insert(zone1));
+  BOOST_CHECK_GT(zone1.getId(), 0);
+
+  Zone zone2;
+  zone2.setName("/net");
+  session.find(zone2);
+  BOOST_CHECK_EQUAL(zone2.getId(), zone1.getId());
+  BOOST_CHECK_EQUAL(zone2.getTtl(), zone1.getTtl());
+
+  BOOST_CHECK_NO_THROW(session.insert(zone2)); // zone2 already has id.  Nothing to execute
+
+  zone2.setId(0);
+  BOOST_CHECK_THROW(session.insert(zone2), ndns::DbMgr::ExecuteError);
+
+  BOOST_CHECK_NO_THROW(session.remove(zone1));
+  BOOST_CHECK_EQUAL(zone1.getId(), 0);
+
+  // record shouldn't exist at this point
+  BOOST_CHECK_NO_THROW(session.find(zone2));
+  BOOST_CHECK_EQUAL(zone2.getId(), 0);
+}
+
+BOOST_FIXTURE_TEST_CASE(Rrsets, DbMgrFixture)
+{
+  Zone zone("/net");
+  Rrset rrset1(&zone);
+
+  // Add
+
+  rrset1.setLabel("/net/ksk-123");
+  rrset1.setType(name::Component("ID-CERT"));
+  rrset1.setVersion(name::Component::fromVersion(567));
+  rrset1.setTtl(time::seconds(4600));
+
+  static const std::string DATA1 = "SOME DATA";
+  rrset1.setData(dataBlock(ndn::tlv::Content, DATA1.c_str(), DATA1.size()));
+
+  BOOST_CHECK_EQUAL(rrset1.getId(), 0);
+  BOOST_CHECK_NO_THROW(session.insert(rrset1));
+  BOOST_CHECK_GT(rrset1.getId(), 0);
+  BOOST_CHECK_GT(rrset1.getZone()->getId(), 0);
+
+  // Lookup
+
+  Rrset rrset2(&zone);
+  rrset2.setLabel("/net/ksk-123");
+  rrset2.setType(name::Component("ID-CERT"));
+
+  bool isFound = false;
+  BOOST_CHECK_NO_THROW(isFound = session.find(rrset2));
+  BOOST_CHECK_EQUAL(isFound, true);
+
+  BOOST_CHECK_EQUAL(rrset2.getId(),      rrset1.getId());
+  BOOST_CHECK_EQUAL(rrset2.getLabel(),   rrset1.getLabel());
+  BOOST_CHECK_EQUAL(rrset2.getType(),    rrset1.getType());
+  BOOST_CHECK_EQUAL(rrset2.getVersion(), rrset1.getVersion());
+  BOOST_CHECK_EQUAL(rrset2.getTtl(),     rrset1.getTtl());
+  BOOST_CHECK(rrset2.getData() == rrset1.getData());
+
+  // Replace
+
+  rrset1.setVersion(name::Component::fromVersion(890));
+  static const std::string DATA2 = "ANOTHER DATA";
+  rrset1.setData(dataBlock(ndn::tlv::Content, DATA2.c_str(), DATA2.size()));
+
+  BOOST_CHECK_NO_THROW(session.update(rrset1));
+
+  rrset2 = Rrset(&zone);
+  rrset2.setLabel("/net/ksk-123");
+  rrset2.setType(name::Component("ID-CERT"));
+
+  isFound = false;
+  BOOST_CHECK_NO_THROW(isFound = session.find(rrset2));
+  BOOST_CHECK_EQUAL(isFound, true);
+
+  BOOST_CHECK_EQUAL(rrset2.getId(),      rrset1.getId());
+  BOOST_CHECK_EQUAL(rrset2.getLabel(),   rrset1.getLabel());
+  BOOST_CHECK_EQUAL(rrset2.getType(),    rrset1.getType());
+  BOOST_CHECK_EQUAL(rrset2.getVersion(), rrset1.getVersion());
+  BOOST_CHECK_EQUAL(rrset2.getTtl(),     rrset1.getTtl());
+  BOOST_CHECK(rrset2.getData() == rrset1.getData());
+
+  // Remove
+
+  BOOST_CHECK_NO_THROW(session.remove(rrset1));
+
+  rrset2 = Rrset(&zone);
+  rrset2.setLabel("/net/ksk-123");
+  rrset2.setType(name::Component("ID-CERT"));
+
+  isFound = false;
+  BOOST_CHECK_NO_THROW(isFound = session.find(rrset2));
+  BOOST_CHECK_EQUAL(isFound, false);
+
+  // Check error handling
+
+  rrset1 = Rrset();
+  BOOST_CHECK_THROW(session.insert(rrset1),  ndns::DbMgr::RrsetError);
+  BOOST_CHECK_THROW(session.find(rrset1),  ndns::DbMgr::RrsetError);
+
+  rrset1.setId(1);
+  BOOST_CHECK_THROW(session.update(rrset1), ndns::DbMgr::RrsetError);
+
+  rrset1.setId(0);
+  rrset1.setZone(&zone);
+  BOOST_CHECK_THROW(session.update(rrset1), ndns::DbMgr::RrsetError);
+
+  BOOST_CHECK_THROW(session.remove(rrset1),  ndns::DbMgr::RrsetError);
+
+  rrset1.setId(1);
+  BOOST_CHECK_NO_THROW(session.remove(rrset1));
+
+  rrset1.setZone(0);
+  rrset1.setId(1);
+  BOOST_CHECK_NO_THROW(session.remove(rrset1));
+}
+
+
+BOOST_FIXTURE_TEST_CASE(FindRrsets, DbMgrFixture)
+{
+  Zone zone("/");
+  Rrset rrset1(&zone);
+  rrset1.setLabel("/net/ksk-123");
+  rrset1.setType(name::Component("ID-CERT"));
+  rrset1.setVersion(name::Component::fromVersion(567));
+  rrset1.setTtl(time::seconds(4600));
+
+  static const std::string DATA1 = "SOME DATA";
+  rrset1.setData(dataBlock(ndn::tlv::Content, DATA1.data(), DATA1.size()));
+  session.insert(rrset1);
+
+  Rrset rrset2(&zone);
+  rrset2.setLabel("/net");
+  rrset2.setType(name::Component("NS"));
+  rrset2.setVersion(name::Component::fromVersion(232));
+  rrset2.setTtl(time::seconds(2100));
+  std::string data2 = "host1.net";
+  rrset2.setData(dataBlock(ndn::tlv::Content, data2.c_str(), data2.size()));
+  session.insert(rrset2);
+
+  std::vector<Rrset> vec = session.findRrsets(zone);
+  BOOST_CHECK_EQUAL(vec.size(), 2);
+
+  std::sort(vec.begin(),
+            vec.end(),
+            [] (const Rrset& n1, const Rrset& n2) {
+              return n1.getLabel().size() < n2.getLabel().size();
+            });
+  BOOST_CHECK_EQUAL(vec[0].getLabel(), "/net");
+  BOOST_CHECK_EQUAL(vec[1].getLabel(), "/net/ksk-123");
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace ndns
+} // namespace ndn
diff --git a/tests/unit/database-test-data.cpp b/tests/unit/database-test-data.cpp
new file mode 100644
index 0000000..3db2335
--- /dev/null
+++ b/tests/unit/database-test-data.cpp
@@ -0,0 +1,180 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, Regents of the University of California.
+ *
+ * This file is part of NDNS (Named Data Networking Domain Name Service).
+ * See AUTHORS.md for complete list of NDNS authors and contributors.
+ *
+ * NDNS is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "database-test-data.hpp"
+#include "logger.hpp"
+
+#include <boost/filesystem.hpp>
+
+namespace ndn {
+namespace ndns {
+namespace tests {
+NDNS_LOG_INIT("TestFakeData")
+
+const boost::filesystem::path DbTestData::TEST_DATABASE = TEST_CONFIG_PATH "/" "test-ndns.db";
+const Name DbTestData::TEST_IDENTITY_NAME("/");
+const boost::filesystem::path DbTestData::TEST_CERT =
+  TEST_CONFIG_PATH "/" "anchors/root.cert";
+
+DbTestData::DbTestData()
+  : doesTestIdentityExist(false)
+  , m_session(TEST_DATABASE.string())
+{
+  NDNS_LOG_TRACE("start creating test data");
+  // m_session.clearAllData();
+
+  ndns::Validator::VALIDATOR_CONF_FILE = TEST_CONFIG_PATH "/" "validator.conf";
+
+  if (!m_keyChain.doesIdentityExist(TEST_IDENTITY_NAME)) {
+    m_keyChain.createIdentity(TEST_IDENTITY_NAME);
+  }
+  else {
+    doesTestIdentityExist = true;
+  }
+
+  m_keyName = m_keyChain.generateRsaKeyPair(TEST_IDENTITY_NAME, false);
+
+  shared_ptr<IdentityCertificate> scert = m_keyChain.selfSign(m_keyName);
+  m_keyChain.addCertificate(*scert);
+  m_certName = scert->getName();
+
+  ndn::io::save(*scert, TEST_CERT.string());
+  NDNS_LOG_TRACE("test key: " << m_keyName);
+  NDNS_LOG_TRACE("save test root cert " << m_certName << " to: " << TEST_CERT.string());
+
+  BOOST_CHECK_GT(m_certName.size(), 0);
+  NDNS_LOG_TRACE("test certName: " << m_certName);
+
+  Zone root("/");
+  Zone net("/net");
+  Zone ndnsim("/net/ndnsim");
+
+  m_session.insert(root);
+  BOOST_CHECK_GT(root.getId(), 0);
+  m_session.insert(net);
+  BOOST_CHECK_GT(net.getId(), 0);
+  m_session.insert(ndnsim);
+  BOOST_CHECK_GT(ndnsim.getId(), 0);
+
+  m_zones.push_back(root);
+  m_zones.push_back(net);
+  m_zones.push_back(ndnsim);
+
+  int certificateIndex = 0;
+  function<void(const Name&,Zone&,const name::Component&)> addQueryRrset =
+    [this, &certificateIndex] (const Name& label, Zone& zone,
+                               const name::Component& type) {
+    const time::seconds ttl(3000 + 100 * certificateIndex);
+    const name::Component version = name::Component::fromVersion(100 + 1000 * certificateIndex);
+    name::Component qType(label::NDNS_ITERATIVE_QUERY);
+    NdnsType ndnsType = NDNS_RESP;
+    if (type == label::CERT_RR_TYPE) {
+      ndnsType = NDNS_RAW;
+      qType = label::NDNS_CERT_QUERY;
+    }
+    std::ostringstream os;
+    os << "a fake content: " << (++certificateIndex) << "th";
+
+    addRrset(zone, label, type, ttl, version, qType, ndnsType, os.str());
+  };
+  addQueryRrset("/dsk-1", root, label::CERT_RR_TYPE);
+  addQueryRrset("/net/ksk-2", root, label::CERT_RR_TYPE);
+  addQueryRrset("/dsk-3", net, label::CERT_RR_TYPE);
+  addQueryRrset("/ndnsim/ksk-4", net, label::CERT_RR_TYPE);
+  addQueryRrset("/dsk-5", ndnsim, label::CERT_RR_TYPE);
+
+  addQueryRrset("net", root, label::NS_RR_TYPE);
+  addQueryRrset("ndnsim", net, label::NS_RR_TYPE);
+  addQueryRrset("www", ndnsim, label::TXT_RR_TYPE);
+  addQueryRrset("doc/www", ndnsim, label::TXT_RR_TYPE);
+
+
+  addRrset(ndnsim, Name("doc"), label::NS_RR_TYPE , time::seconds(2000),
+    name::Component("1234"), label::NDNS_ITERATIVE_QUERY, NDNS_AUTH, std::string(""));
+
+  NDNS_LOG_INFO("insert testing data: OK");
+}
+
+
+
+void
+DbTestData::addRrset(Zone& zone, const Name& label, const name::Component& type,
+                     const time::seconds& ttl, const name::Component& version,
+                     const name::Component& qType, NdnsType ndnsType, const std::string& msg)
+{
+  Rrset rrset(&zone);
+  rrset.setLabel(label);
+  rrset.setType(type);
+  rrset.setTtl(ttl);
+  rrset.setVersion(version);
+
+  Response re;
+  re.setZone(zone.getName());
+  re.setQueryType(qType);
+  re.setRrLabel(label);
+  re.setRrType(type);
+  re.setVersion(version);
+  re.setNdnsType(ndnsType);
+  re.setFreshnessPeriod(ttl);
+
+  if (msg.size() > 0) {
+    if (type == label::CERT_RR_TYPE)
+      re.setAppContent(dataBlock(ndn::tlv::Content, msg.c_str(), msg.size()));
+    else
+      re.addRr(msg);
+  }
+  shared_ptr<Data> data = re.toData();
+  m_keyChain.sign(*data, m_certName); // now we ignore the certificate to sign the data
+  shared_ptr<IdentityCertificate> cert = m_keyChain.getCertificate(m_certName);
+  BOOST_CHECK_EQUAL(Validator::verifySignature(*data, cert->getPublicKeyInfo()), true);
+  rrset.setData(data->wireEncode());
+
+  m_session.insert(rrset);
+
+  m_rrsets.push_back(rrset);
+}
+
+DbTestData::~DbTestData()
+{
+  for (auto& zone : m_zones)
+    m_session.remove(zone);
+
+  for (auto& rrset : m_rrsets)
+    m_session.remove(rrset);
+
+  m_session.close();
+
+  boost::filesystem::remove(TEST_DATABASE);
+  boost::filesystem::remove(TEST_CERT);
+
+  if (doesTestIdentityExist) {
+    m_keyChain.deleteCertificate(m_certName);
+    m_keyChain.deleteKey(m_keyName);
+    NDNS_LOG_TRACE("delete key: " << m_keyName << " and certificate: " << m_certName);
+  }
+  else{
+    m_keyChain.deleteIdentity(TEST_IDENTITY_NAME);
+  }
+
+  NDNS_LOG_INFO("remove database: " << TEST_DATABASE);
+}
+
+} // namespace tests
+} // namespace ndns
+} // namespace ndn
diff --git a/tests/unit/database-test-data.hpp b/tests/unit/database-test-data.hpp
new file mode 100644
index 0000000..38b1d43
--- /dev/null
+++ b/tests/unit/database-test-data.hpp
@@ -0,0 +1,68 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014, Regents of the University of California.
+ *
+ * This file is part of NDNS (Named Data Networking Domain Name Service).
+ * See AUTHORS.md for complete list of NDNS authors and contributors.
+ *
+ * NDNS is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NDNS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NDNS, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NDNS_TESTS_UNIT_DATABASE_TEST_DATA_HPP
+#define NDNS_TESTS_UNIT_DATABASE_TEST_DATA_HPP
+
+#include "daemon/db-mgr.hpp"
+#include "clients/response.hpp"
+#include "clients/query.hpp"
+#include "validator.hpp"
+
+#include "../boost-test.hpp"
+
+#include <ndn-cxx/security/key-chain.hpp>
+#include <boost/filesystem.hpp>
+
+namespace ndn {
+namespace ndns {
+namespace tests {
+
+class DbTestData
+{
+public:
+  static const boost::filesystem::path TEST_DATABASE;
+  static const Name TEST_IDENTITY_NAME;
+  static const boost::filesystem::path TEST_CERT;
+
+  DbTestData();
+
+  ~DbTestData();
+
+private:
+  void
+  addRrset(Zone& zone, const Name& label, const name::Component& type,
+                       const time::seconds& ttl, const name::Component& version,
+                       const name::Component& qType, NdnsType ndnsType, const std::string& msg);
+public:
+  Name m_certName;
+  Name m_keyName;
+  std::vector<Zone>  m_zones;
+  std::vector<Rrset> m_rrsets;
+
+  bool doesTestIdentityExist;
+  DbMgr m_session;
+  KeyChain m_keyChain;
+};
+
+} // namespace tests
+} // namespace ndns
+} // namespace ndn
+
+#endif // NDNS_TESTS_UNIT_DATABASE_TEST_DATA_HPP
diff --git a/tests/unit/logger.cpp b/tests/unit/logger.cpp
index 100aa5b..c2491ad 100644
--- a/tests/unit/logger.cpp
+++ b/tests/unit/logger.cpp
@@ -19,6 +19,7 @@
 
 #include "logger.hpp"
 #include "../boost-test.hpp"
+#include "config.hpp"
 
 #include <fstream>
 
