diff --git a/tests/unit-tests/action-log.t.cpp b/tests/unit-tests/action-log.t.cpp
index 2281026..8d874bc 100644
--- a/tests/unit-tests/action-log.t.cpp
+++ b/tests/unit-tests/action-log.t.cpp
@@ -18,78 +18,87 @@
  * See AUTHORS.md for complete list of ChronoShare authors and contributors.
  */
 
-#include <boost/lexical_cast.hpp>
-#include <boost/test/unit_test.hpp>
-
 #include "action-log.hpp"
-#include "logging.hpp"
 
-#include <boost/filesystem.hpp>
-#include <boost/make_shared.hpp>
-#include <iostream>
-#include <unistd.h>
+#include "test-common.hpp"
+#include "dummy-forwarder.hpp"
 
-using namespace std;
-using namespace boost;
-using namespace Ndnx;
+namespace ndn {
+namespace chronoshare {
+namespace tests {
+
 namespace fs = boost::filesystem;
 
-BOOST_AUTO_TEST_SUITE(TestActionLog)
-
-BOOST_AUTO_TEST_CASE(ActionLogTest)
+class TestActionLogFixture : public IdentityManagementTimeFixture
 {
-  Name localName("/alex");
+public:
+  TestActionLogFixture()
+    : forwarder(m_io, m_keyChain)
+    , localName("/lijing")
+    , tmpdir(fs::unique_path(UNIT_TEST_CONFIG_PATH))
+  {
+    if (exists(tmpdir)) {
+      remove_all(tmpdir);
+    }
 
-  fs::path tmpdir = fs::unique_path(fs::temp_directory_path() / "%%%%-%%%%-%%%%-%%%%");
-  SyncLogPtr syncLog = make_shared<SyncLog>(tmpdir, localName);
-  CcnxWrapperPtr ccnx = make_shared<CcnxWrapper>();
+    syncLog = make_shared<SyncLog>(tmpdir, localName);
+  }
 
-  ActionLogPtr actionLog =
-    make_shared<ActionLog>(ccnx, tmpdir, syncLog, "top-secret", "test-chronoshare",
-                           ActionLog::OnFileAddedOrChangedCallback(),
-                           ActionLog::OnFileRemovedCallback());
+public:
+  DummyForwarder forwarder;
+  Name localName;
+  fs::path tmpdir;
+  shared_ptr<SyncLog> syncLog;
+};
 
-  // const std::string &filename,
-  //                    const Hash &hash,
-  //                    time_t wtime,
-  //                    int mode,
-  //                    int seg_num
+BOOST_FIXTURE_TEST_SUITE(TestActionLog, TestActionLogFixture)
+
+BOOST_AUTO_TEST_CASE(UpdateAction)
+{
+  auto actionLog = std::make_shared<ActionLog>(forwarder.addFace(), tmpdir, syncLog,
+                                               "top-secret", "test-chronoshare",
+                                               ActionLog::OnFileAddedOrChangedCallback(),
+                                               ActionLog::OnFileRemovedCallback());
+
   BOOST_CHECK_EQUAL(syncLog->SeqNo(localName), 0);
 
   BOOST_CHECK_EQUAL(syncLog->LogSize(), 0);
   BOOST_CHECK_EQUAL(actionLog->LogSize(), 0);
 
   actionLog->AddLocalActionUpdate("file.txt",
-                                  *Hash::FromString(
-                                    "2ff304769cdb0125ac039e6fe7575f8576dceffc62618a431715aaf6eea2bf1c"),
-                                  time(NULL), 0755, 10);
+                                  *fromHex("2ff304769cdb0125ac039e6fe7575f8576dceffc62618a431715aaf6eea2bf1c"),
+                                  std::time(nullptr), 0755, 10);
 
   BOOST_CHECK_EQUAL(syncLog->SeqNo(localName), 1);
   BOOST_CHECK_EQUAL(syncLog->LogSize(), 0);
   BOOST_CHECK_EQUAL(actionLog->LogSize(), 1);
 
-  HashPtr hash = syncLog->RememberStateInStateLog();
+  ndn::ConstBufferPtr hash = syncLog->RememberStateInStateLog();
   BOOST_CHECK_EQUAL(syncLog->LogSize(), 1);
-  BOOST_CHECK_EQUAL(lexical_cast<string>(*hash),
-                    "3410477233f98d6c3f9a6f8da24494bf5a65e1a7c9f4f66b228128bd4e020558");
+  BOOST_CHECK_EQUAL(toHex(*hash),
+                    "91A849EEDE75ACD56AE1BCB99E92D8FB28757683BC387DBB0E59C3108FCF4F18");
 
-  PcoPtr pco = actionLog->LookupActionPco(localName, 0);
-  BOOST_CHECK_EQUAL((bool)pco, false);
+  ndn::shared_ptr<ndn::Data> data = actionLog->LookupActionData(localName, 0);
 
-  pco = actionLog->LookupActionPco(localName, 1);
-  BOOST_CHECK_EQUAL((bool)pco, true);
+  BOOST_CHECK_EQUAL(bool(data), false);
 
-  BOOST_CHECK_EQUAL(pco->name(), "/alex/test-chronoshare/action/top-secret/%00%01");
+  data = actionLog->LookupActionData(localName, 1);
 
-  ActionItemPtr action = actionLog->LookupAction(Name("/alex/test-chronoshare/action/top-secret")(0));
+  BOOST_CHECK_EQUAL(bool(data), true);
+
+  BOOST_CHECK_EQUAL(data->getName(), "/lijing/test-chronoshare/action/top-secret/%01");
+
+  ActionItemPtr action =
+    actionLog->LookupAction(Name("/lijing/test-chronoshare/action/top-secret").appendNumber(0));
   BOOST_CHECK_EQUAL((bool)action, false);
 
-  action = actionLog->LookupAction(Name("/alex/test-chronoshare/action/top-secret")(1));
+  action =
+    actionLog->LookupAction(Name("/lijing/test-chronoshare/action/top-secret").appendNumber(1));
   BOOST_CHECK_EQUAL((bool)action, true);
 
   if (action) {
     BOOST_CHECK_EQUAL(action->version(), 0);
-    BOOST_CHECK_EQUAL(action->action(), 0);
+    BOOST_CHECK_EQUAL(action->action(), ActionItem::UPDATE);
 
     BOOST_CHECK_EQUAL(action->filename(), "file.txt");
     BOOST_CHECK_EQUAL(action->seg_num(), 10);
@@ -101,14 +110,13 @@
   }
 
   actionLog->AddLocalActionUpdate("file.txt",
-                                  *Hash::FromString(
-                                    "2ff304769cdb0125ac039e6fe7575f8576dceffc62618a431715aaf6eea2bf1c"),
-                                  time(NULL), 0755, 10);
+                                  *fromHex("2ff304769cdb0125ac039e6fe7575f8576dceffc62618a431715aaf6eea2bf1c"),
+                                  std::time(nullptr), 0755, 10);
   BOOST_CHECK_EQUAL(syncLog->SeqNo(localName), 2);
   BOOST_CHECK_EQUAL(syncLog->LogSize(), 1);
   BOOST_CHECK_EQUAL(actionLog->LogSize(), 2);
 
-  action = actionLog->LookupAction(Name("/alex"), 2);
+  action = actionLog->LookupAction(Name("/lijing"), 2);
   BOOST_CHECK_EQUAL((bool)action, true);
 
   if (action) {
@@ -119,30 +127,120 @@
     BOOST_CHECK_EQUAL(action->version(), 1);
   }
 
-  BOOST_CHECK_EQUAL((bool)actionLog->AddRemoteAction(pco), true);
+  BOOST_CHECK_EQUAL((bool)actionLog->AddRemoteAction(data), true);
   BOOST_CHECK_EQUAL(actionLog->LogSize(), 2);
 
   // create a real remote action
-  ActionItem item;
-  item.set_action(ActionItem::UPDATE);
-  item.set_filename("file.txt");
-  item.set_version(2);
-  item.set_timestamp(time(NULL));
+  ActionItemPtr item = make_shared<ActionItem>();
+  item->set_action(ActionItem::UPDATE);
+  item->set_filename("file.txt");
+  item->set_version(2);
+  item->set_timestamp(std::time(nullptr));
 
-  BytesPtr item_msg = serializeMsg(item);
-  Name actionName = Name("/")(Name("/zhenkai/test"))("test-chronoshare")("action")("top-secret")(1);
-  Bytes actionData = ccnx->createContentObject(actionName, head(*item_msg), item_msg->size());
+  std::string item_msg;
+  item->SerializeToString(&item_msg);
 
-  pco = make_shared<ParsedContentObject>(actionData);
-  BOOST_CHECK_EQUAL((bool)actionLog->AddRemoteAction(pco), true);
+  Name actionName = Name("/zhenkai/test/test-chronoshare/action/top-secret").appendNumber(1);
+
+  ndn::shared_ptr<Data> actionData = ndn::make_shared<Data>();
+  actionData->setName(actionName);
+  actionData->setContent(reinterpret_cast<const uint8_t*>(item_msg.c_str()), item_msg.size());
+  ndn::KeyChain m_keyChain;
+  m_keyChain.sign(*actionData);
+
+  BOOST_CHECK_EQUAL((bool)actionLog->AddRemoteAction(actionData), true);
   BOOST_CHECK_EQUAL(actionLog->LogSize(), 3);
+}
 
-  remove_all(tmpdir);
+BOOST_AUTO_TEST_CASE(DeleteAction)
+{
+  bool hasDeleteCallbackCalled = false;
+  auto actionLog = std::make_shared<ActionLog>(forwarder.addFace(), tmpdir, syncLog,
+                                               "top-secret", "test-chronoshare",
+                                               ActionLog::OnFileAddedOrChangedCallback(),
+                                               bind([&] { hasDeleteCallbackCalled = true; }));
+
+  BOOST_CHECK_EQUAL(syncLog->SeqNo(localName), 0);
+
+  BOOST_CHECK_EQUAL(syncLog->LogSize(), 0);
+  BOOST_CHECK_EQUAL(actionLog->LogSize(), 0);
+
+  actionLog->AddLocalActionUpdate("file.txt",
+                                  *fromHex("2ff304769cdb0125ac039e6fe7575f8576dceffc62618a431715aaf6eea2bf1c"),
+                                  std::time(nullptr), 0755, 10);
+
+  BOOST_CHECK_EQUAL(syncLog->SeqNo(localName), 1);
+  BOOST_CHECK_EQUAL(syncLog->LogSize(), 0);
+  BOOST_CHECK_EQUAL(actionLog->LogSize(), 1);
+
+  syncLog->RememberStateInStateLog();
+
+  actionLog->AddLocalActionDelete("file.txt");
+  BOOST_CHECK_EQUAL(syncLog->SeqNo(localName), 2);
+  BOOST_CHECK_EQUAL(syncLog->LogSize(), 1);
+  BOOST_CHECK_EQUAL(actionLog->LogSize(), 2);
+  BOOST_CHECK(hasDeleteCallbackCalled);
+
+  ndn::ConstBufferPtr hash = syncLog->RememberStateInStateLog();
+  BOOST_CHECK_EQUAL(syncLog->LogSize(), 2);
+  BOOST_CHECK_EQUAL(toHex(*hash),
+                    "D2DFEDA56ED98C0E17D455A859BC8C3B9E31C85C138C280A8BADAB4FC551F282");
+
+  ndn::shared_ptr<ndn::Data> data = actionLog->LookupActionData(localName, 2);
+  BOOST_CHECK(data != nullptr);
+
+  BOOST_CHECK_EQUAL(data->getName(), "/lijing/test-chronoshare/action/top-secret/%02");
+
+  ActionItemPtr action = actionLog->LookupAction(Name("/lijing/test-chronoshare/action/top-secret").appendNumber(2));
+  BOOST_CHECK(action != nullptr);
+
+  if (action) {
+    BOOST_CHECK_EQUAL(action->version(), 1);
+    BOOST_CHECK_EQUAL(action->action(), ActionItem::DELETE);
+
+    BOOST_CHECK_EQUAL(action->filename(), "file.txt");
+
+    BOOST_CHECK_EQUAL(Name(Block(action->parent_device_name().data(), action->parent_device_name().size())),
+                      Name("/lijing"));
+    BOOST_CHECK_EQUAL(action->parent_seq_no(), 1);
+  }
+
+  BOOST_CHECK_EQUAL((bool)actionLog->AddRemoteAction(data), true);
+  BOOST_CHECK_EQUAL(actionLog->LogSize(), 2);
+
+  // create a real remote action
+  ActionItemPtr item = make_shared<ActionItem>();
+  item->set_action(ActionItem::DELETE);
+  item->set_filename("file.txt");
+  item->set_version(2);
+  item->set_timestamp(std::time(0));
+
+  std::string filename = "file.txt";
+  BufferPtr parent_device_name = std::make_shared<Buffer>(filename.c_str(), filename.size());
+  item->set_parent_device_name(parent_device_name->buf(), parent_device_name->size());
+  item->set_parent_seq_no(0);
+
+  std::string item_msg;
+  item->SerializeToString(&item_msg);
+
+  Name actionName = Name("/yukai/test/test-chronoshare/action/top-secret").appendNumber(1);
+
+  ndn::shared_ptr<Data> actionData = ndn::make_shared<Data>();
+  actionData->setName(actionName);
+  actionData->setContent(reinterpret_cast<const uint8_t*>(item_msg.c_str()), item_msg.size());
+  ndn::KeyChain m_keyChain;
+  m_keyChain.sign(*actionData);
+
+  ActionItemPtr actionItem = actionLog->AddRemoteAction(actionData);
+  BOOST_CHECK_EQUAL((bool)actionItem, true);
+  BOOST_CHECK_EQUAL(actionLog->LogSize(), 3);
+  BOOST_CHECK_EQUAL(syncLog->LogSize(), 2);
+
+  BOOST_CHECK_EQUAL(action->action(), ActionItem::DELETE);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
 
-// catch (boost::exception &err)
-//   {
-//     cout << *boost::get_error_info<errmsg_info_str> (err) << endl;
-//   }
+} // namespace tests
+} // namespace chronoshare
+} // namespace ndn
