diff --git a/src/test/java/com/intel/jndn/management/NdnPingClientIT.java b/src/test/java/com/intel/jndn/management/NdnPingClientIT.java
index 762ae7c..18a6269 100644
--- a/src/test/java/com/intel/jndn/management/NdnPingClientIT.java
+++ b/src/test/java/com/intel/jndn/management/NdnPingClientIT.java
@@ -15,17 +15,16 @@
 
 import net.named_data.jndn.Face;
 import net.named_data.jndn.Name;
-import net.named_data.jndn.security.SecurityException;
+import net.named_data.jndn.encoding.Tlv0_3WireFormat;
+import net.named_data.jndn.encoding.WireFormat;
+
 import org.junit.Before;
 import org.junit.Test;
-
-import java.io.IOException;
-
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 /**
- * Testing basic pining using real NFD instance (NFD must be run locally while executing the test).
+ * Testing basic pinging using real NFD instance (NFD must be run locally while executing the test).
  *
  * @author Andrew Brown <andrew.brown@intel.com>
  */
@@ -33,12 +32,14 @@
   private Face face;
 
   @Before
-  public void setUp() throws SecurityException {
+  public void setUp() {
+    WireFormat.setDefaultWireFormat(Tlv0_3WireFormat.get());
+
     face = new Face("localhost");
   }
 
   @Test
-  public void testPingLocal() throws IOException, ManagementException {
+  public void testPingLocal() {
     boolean hasSucceeded = NdnPingClient.pingLocal(face);
     assertTrue(hasSucceeded);
   }
diff --git a/src/test/java/com/intel/jndn/management/NfdcIT.java b/src/test/java/com/intel/jndn/management/NfdcIT.java
index 7baaf22..98e11cf 100644
--- a/src/test/java/com/intel/jndn/management/NfdcIT.java
+++ b/src/test/java/com/intel/jndn/management/NfdcIT.java
@@ -14,34 +14,24 @@
 package com.intel.jndn.management;
 
 import com.intel.jndn.management.enums.Strategies;
+import com.intel.jndn.management.types.ForwarderStatus;
 import com.intel.jndn.management.types.RibEntry;
 import com.intel.jndn.management.types.StrategyChoice;
-import com.intel.jndn.mock.MockFace;
 import com.intel.jndn.mock.MockKeyChain;
-import net.named_data.jndn.ControlResponse;
-import net.named_data.jndn.Data;
-import net.named_data.jndn.DigestSha256Signature;
 import net.named_data.jndn.Face;
-import net.named_data.jndn.Interest;
-import net.named_data.jndn.KeyLocator;
-import net.named_data.jndn.MetaInfo;
 import net.named_data.jndn.Name;
-import net.named_data.jndn.encoding.EncodingException;
 import net.named_data.jndn.encoding.Tlv0_3WireFormat;
 import net.named_data.jndn.encoding.WireFormat;
 import net.named_data.jndn.security.KeyChain;
 import net.named_data.jndn.security.SecurityException;
-import org.junit.Before;
-import org.junit.Test;
 
-import java.io.IOException;
 import java.util.List;
 import java.util.Random;
-import java.util.logging.Logger;
 
+import org.junit.Before;
+import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
@@ -51,9 +41,7 @@
  * @author Andrew Brown <andrew.brown@intel.com>
  */
 public class NfdcIT {
-  private static final Logger LOG = Logger.getLogger(NfdcIT.class.getName());
   private Face face;
-  private MockFace mockFace;
   private Face noKeyChainFace;
 
   @Before
@@ -61,87 +49,53 @@
     WireFormat.setDefaultWireFormat(Tlv0_3WireFormat.get());
 
     face = new Face("localhost");
-    mockFace = new MockFace(new MockFace.Options().setEnablePacketLogging(false).setEnableRegistrationReply(false));
-    noKeyChainFace = new Face("localhost"); // don't set command signing info
     KeyChain keyChain = MockKeyChain.configure(new Name("/tmp/identity"));
     face.setCommandSigningInfo(keyChain, keyChain.getDefaultCertificateName());
-  }
-
-  @Test
-  public void testGetKeyLocator() throws Exception {
-    KeyLocator keyLocator = Nfdc.getKeyLocator(face);
-    assertNotNull(keyLocator);
-    LOG.info("Connected to NFD with key locator: " + keyLocator.getKeyName().toUri());
-
-    assertThrows(ManagementException.class, () -> Nfdc.getKeyLocator(mockFace));
-  }
-
-  @Test
-  public void testFailOfGetKeyLocator() throws Exception {
-    mockFace.onSendInterest.add(new MockFace.SignalOnSendInterest() {
-      @Override
-      public void emit(final Interest interest) {
-        Data data = new Data();
-        data.setName(new Name(interest.getName()).appendVersion(0).appendSegment(0));
-
-        MetaInfo meta = new MetaInfo();
-        meta.setFinalBlockId(data.getName().get(-1));
-        data.setMetaInfo(meta);
-
-        data.setSignature(new DigestSha256Signature());
-
-        LOG.info(data.getSignature().toString());
-
-        // don't set anything else
-        try {
-          mockFace.receive(data);
-        } catch (EncodingException e) {
-          LOG.severe("Failed to set receive data: " + e);
-        }
-      }
-    });
-
-    Exception exception = assertThrows(ManagementException.class, () -> Nfdc.getKeyLocator(mockFace));
-    assertEquals("No key locator available.", exception.getMessage());
+    noKeyChainFace = new Face("localhost"); // don't set command signing info
   }
 
   @Test
   public void testGetForwarderStatus() throws Exception {
-    assertTrue(Nfdc.getForwarderStatus(face).getStartTimestamp() > 0);
-    assertThrows(ManagementException.class, () -> Nfdc.getForwarderStatus(mockFace));
+    ForwarderStatus status = Nfdc.getForwarderStatus(face);
+    assertTrue(status.getStartTimestamp() > 0);
+    assertTrue(status.getCurrentTimestamp() > 0);
+    assertTrue(status.getNFibEntries() > 0);
+    assertTrue(status.getNInInterests() > 0);
+    assertTrue(status.getNOutData() > 0);
+  }
+
+  @Test
+  public void testGetChannelStatusList() throws Exception {
+    assertFalse(Nfdc.getChannelStatusList(face).isEmpty());
   }
 
   @Test
   public void testGetFaceList() throws Exception {
     assertFalse(Nfdc.getFaceList(face).isEmpty());
-    assertThrows(ManagementException.class, () -> Nfdc.getFaceList(mockFace));
   }
 
   @Test
   public void testGetFibList() throws Exception {
     assertFalse(Nfdc.getFibList(face).isEmpty());
-    assertThrows(ManagementException.class, () -> Nfdc.getFibList(mockFace));
   }
 
   @Test
   public void testGetRouteList() throws Exception {
     assertFalse(Nfdc.getRouteList(face).isEmpty());
-    assertThrows(ManagementException.class, () -> Nfdc.getRouteList(mockFace));
   }
 
   @Test
-  public void testRoutes() throws EncodingException, IOException, ManagementException, InterruptedException {
+  public void testRoutes() throws Exception {
     Nfdc.register(face, new Name("/my/route/to/app/face"), 333);
     int faceId = Nfdc.createFace(face, "udp4://127.0.0.1:56363");
     Nfdc.register(face, "udp4://127.0.0.1:56363", new Name("/my/test/route"), 999);
     Nfdc.register(face, faceId, new Name("/"), 555);
 
-    // check that route is created
     Thread.sleep(1000); // NFD registers the route asynchronously
 
+    // check that route is created
     boolean found = false;
     for (RibEntry route : Nfdc.getRouteList(face)) {
-      LOG.info("Found route: " + route.getName().toUri());
       if (route.getName().equals(new Name("/my/test/route"))) {
         found = true;
       }
@@ -155,7 +109,6 @@
 
     // remove face
     Nfdc.destroyFace(face, faceId);
-
     Thread.sleep(1000); // wait for face to be destroyed
 
     Exception exception = assertThrows(ManagementException.class, () -> {
@@ -165,29 +118,10 @@
   }
 
   @Test
-  public void testFailOfRegister() throws Exception {
-    assertThrows(ManagementException.class, () -> Nfdc.register(mockFace, new Name("/my/route/to/app/face"), 333));
-  }
-
-  @Test
-  public void testFailOfUnregister() throws Exception {
-    assertThrows(ManagementException.class, () -> Nfdc.unregister(mockFace, new Name("/my/route/to/app/face")));
-  }
-
-  @Test
-  public void testFailOfCreateFace() throws Exception {
-    assertThrows(ManagementException.class, () -> Nfdc.createFace(mockFace, "udp4://127.0.0.1:56363"));
-  }
-
-  @Test
-  public void testFailOfDestroyFace() throws Exception {
-    assertThrows(ManagementException.class, () -> Nfdc.destroyFace(mockFace, 1));
-  }
-
-  @Test
   public void testStrategies() throws Exception {
     Name prefix = new Name("/test/strategy").append("random" + new Random().nextInt());
     List<StrategyChoice> choices = Nfdc.getStrategyList(face);
+    assertFalse(choices.isEmpty());
     int oldSize = choices.size();
 
     Nfdc.setStrategy(face, prefix, Strategies.RANDOM);
@@ -201,13 +135,6 @@
 
     choices = Nfdc.getStrategyList(face);
     assertEquals(oldSize, choices.size());
-
-    assertThrows(ManagementException.class, () -> Nfdc.getStrategyList(mockFace));
-  }
-
-  @Test
-  public void testFailOfUnsetStrategy() throws Exception {
-    assertThrows(ManagementException.class, () -> Nfdc.unsetStrategy(mockFace, new Name("/")));
   }
 
   @Test
@@ -216,37 +143,4 @@
                    Nfdc.setStrategy(noKeyChainFace, new Name("/test"), Strategies.BEST_ROUTE);
                  });
   }
-
-  @Test
-  public void testFailOfSetStrategyWithNon200Code() throws Exception {
-    mockFace.onSendInterest.add(new MockFace.SignalOnSendInterest() {
-      @Override
-      public void emit(final Interest interest) {
-        ControlResponse response = new ControlResponse();
-        response.setStatusCode(300);
-        response.setStatusText("Test FAIL");
-
-        Data data = new Data();
-        data.setName(interest.getName());
-        data.setContent(response.wireEncode());
-
-        try {
-          mockFace.receive(data);
-        } catch (EncodingException e) {
-          LOG.severe("Failed to set receive data: " + e);
-        }
-      }
-    });
-
-    Exception exception = assertThrows(ManagementException.class, () -> {
-                                         Nfdc.setStrategy(mockFace, new Name("/"), Strategies.MULTICAST);
-                                       });
-    assertEquals("Action failed, forwarder returned: 300 Test FAIL", exception.getMessage());
-  }
-
-  @Test
-  public void testGetChannelStatus() throws Exception {
-    assertFalse(Nfdc.getChannelStatusList(face).isEmpty());
-    assertThrows(ManagementException.class, () -> Nfdc.getChannelStatusList(mockFace));
-  }
 }
diff --git a/src/test/java/com/intel/jndn/management/NfdcTest.java b/src/test/java/com/intel/jndn/management/NfdcTest.java
new file mode 100644
index 0000000..fe9966c
--- /dev/null
+++ b/src/test/java/com/intel/jndn/management/NfdcTest.java
@@ -0,0 +1,213 @@
+/*
+ * jndn-management
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU Lesser General Public License,
+ * version 3, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
+ * more details.
+ */
+package com.intel.jndn.management;
+
+import com.intel.jndn.management.enums.Strategies;
+import com.intel.jndn.mock.MockFace;
+import com.intel.jndn.mock.MockKeyChain;
+import net.named_data.jndn.ControlResponse;
+import net.named_data.jndn.Data;
+import net.named_data.jndn.Interest;
+import net.named_data.jndn.KeyLocator;
+import net.named_data.jndn.KeyLocatorType;
+import net.named_data.jndn.MetaInfo;
+import net.named_data.jndn.Name;
+import net.named_data.jndn.encoding.Tlv0_3WireFormat;
+import net.named_data.jndn.encoding.WireFormat;
+import net.named_data.jndn.security.KeyChain;
+import net.named_data.jndn.security.SecurityException;
+import net.named_data.jndn.security.SigningInfo;
+
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+/**
+ * Nfdc unit tests.
+ */
+public class NfdcTest {
+  private MockFace mockFace;
+  private KeyChain keyChain;
+  private MockFace.SignalOnSendInterest replyWithEmptyData;
+
+  @Before
+  public void setUp() throws SecurityException {
+    WireFormat.setDefaultWireFormat(Tlv0_3WireFormat.get());
+
+    mockFace = new MockFace(new MockFace.Options());
+    keyChain = MockKeyChain.configure(new Name("/tmp/identity"));
+
+    replyWithEmptyData = new MockFace.SignalOnSendInterest() {
+      @Override
+      public void emit(final Interest interest) {
+        Data data = new Data();
+        data.setName(new Name(interest.getName()).appendVersion(0).appendSegment(0));
+        MetaInfo meta = new MetaInfo();
+        meta.setFinalBlockId(data.getName().get(-1));
+        data.setMetaInfo(meta);
+
+        try {
+          keyChain.sign(data);
+        } catch (Exception e) {
+          fail("Failed to sign data: " + e);
+        }
+
+        try {
+          mockFace.receive(data);
+        } catch (Exception e) {
+          fail("Failed to receive data on mock face: " + e);
+        }
+      }
+    };
+  }
+
+  @Test
+  public void testGetKeyLocator() throws Exception {
+    mockFace.onSendInterest.add(replyWithEmptyData);
+
+    KeyLocator keyLocator = Nfdc.getKeyLocator(mockFace);
+    assertEquals(KeyLocatorType.KEYNAME, keyLocator.getType());
+    assertNotEquals(0, keyLocator.getKeyName().size());
+  }
+
+  @Test
+  public void testGetKeyLocatorWithDigestSha256() throws Exception {
+    mockFace.onSendInterest.add(new MockFace.SignalOnSendInterest() {
+      @Override
+      public void emit(final Interest interest) {
+        Data data = new Data();
+        data.setName(new Name(interest.getName()).appendVersion(0).appendSegment(0));
+        MetaInfo meta = new MetaInfo();
+        meta.setFinalBlockId(data.getName().get(-1));
+        data.setMetaInfo(meta);
+
+        try {
+          keyChain.sign(data, new SigningInfo(SigningInfo.SignerType.SHA256));
+        } catch (Exception e) {
+          fail("Failed to sign data: " + e);
+        }
+
+        try {
+          mockFace.receive(data);
+        } catch (Exception e) {
+          fail("Failed to receive data on mock face: " + e);
+        }
+      }
+    });
+
+    Exception exception = assertThrows(ManagementException.class, () -> Nfdc.getKeyLocator(mockFace));
+    assertEquals("No key locator available.", exception.getMessage());
+  }
+
+  @Test
+  public void testGetChannelStatusList() throws Exception {
+    assertThrows(ManagementException.class, () -> Nfdc.getChannelStatusList(mockFace));
+
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertTrue(Nfdc.getChannelStatusList(mockFace).isEmpty());
+  }
+
+  @Test
+  public void testGetFaceList() throws Exception {
+    assertThrows(ManagementException.class, () -> Nfdc.getFaceList(mockFace));
+
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertTrue(Nfdc.getFaceList(mockFace).isEmpty());
+  }
+
+  @Test
+  public void testFailOfCreateFace() throws Exception {
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertThrows(ManagementException.class, () -> Nfdc.createFace(mockFace, "udp4://127.0.0.1:56363"));
+  }
+
+  @Test
+  public void testFailOfDestroyFace() throws Exception {
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertThrows(ManagementException.class, () -> Nfdc.destroyFace(mockFace, 1));
+  }
+
+  @Test
+  public void testGetFibList() throws Exception {
+    assertThrows(ManagementException.class, () -> Nfdc.getFibList(mockFace));
+
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertTrue(Nfdc.getFibList(mockFace).isEmpty());
+  }
+
+  @Test
+  public void testGetRouteList() throws Exception {
+    assertThrows(ManagementException.class, () -> Nfdc.getRouteList(mockFace));
+
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertTrue(Nfdc.getRouteList(mockFace).isEmpty());
+  }
+
+  @Test
+  public void testFailOfRegister() throws Exception {
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertThrows(ManagementException.class, () -> Nfdc.register(mockFace, new Name("/my/route/to/app/face"), 333));
+  }
+
+  @Test
+  public void testFailOfUnregister() throws Exception {
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertThrows(ManagementException.class, () -> Nfdc.unregister(mockFace, new Name("/my/route/to/app/face")));
+  }
+
+  @Test
+  public void testGetStrategyList() throws Exception {
+    assertThrows(ManagementException.class, () -> Nfdc.getStrategyList(mockFace));
+
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertTrue(Nfdc.getStrategyList(mockFace).isEmpty());
+  }
+
+  @Test
+  public void testFailOfSetStrategyWithNon200Code() throws Exception {
+    mockFace.onSendInterest.add(new MockFace.SignalOnSendInterest() {
+      @Override
+      public void emit(final Interest interest) {
+        ControlResponse response = new ControlResponse();
+        response.setStatusCode(400);
+        response.setStatusText("test error");
+
+        Data data = new Data();
+        data.setName(interest.getName());
+        data.setContent(response.wireEncode());
+
+        try {
+          mockFace.receive(data);
+        } catch (Exception e) {
+          fail("Failed to receive data on mock face: " + e);
+        }
+      }
+    });
+
+    Exception exception = assertThrows(ManagementException.class, () -> {
+                                         Nfdc.setStrategy(mockFace, new Name("/"), Strategies.MULTICAST);
+                                       });
+    assertEquals("Action failed, forwarder returned: 400 test error", exception.getMessage());
+  }
+
+  @Test
+  public void testFailOfUnsetStrategy() throws Exception {
+    mockFace.onSendInterest.add(replyWithEmptyData);
+    assertThrows(ManagementException.class, () -> Nfdc.unsetStrategy(mockFace, new Name("/")));
+  }
+}
