tests: resetGlobalIoService for every test

All tests must use BaseFixture or a fixture derived from it to get this feature.

This commit also fixes a few warnings in tests/mgmt, and moves test cases into nfd::tests namespace.

refs #1290

Change-Id: I891441a5abce170e35648d463f7157b18429f79f
diff --git a/tests/test-common.hpp b/tests/test-common.hpp
new file mode 100644
index 0000000..c17607c
--- /dev/null
+++ b/tests/test-common.hpp
@@ -0,0 +1,42 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NFD_TEST_COMMON_HPP
+#define NFD_TEST_COMMON_HPP
+
+#include <boost/test/unit_test.hpp>
+#include "core/global-io.hpp"
+
+namespace nfd {
+namespace tests {
+
+/** \brief base test fixture
+ *
+ *  Every test case should be based on this fixture,
+ *  to have per test case io_service initialization.
+ */
+class BaseFixture
+{
+protected:
+  BaseFixture()
+    : g_io(getGlobalIoService())
+  {
+  }
+  
+  ~BaseFixture()
+  {
+    resetGlobalIoService();
+  }
+
+protected:
+  /// reference to global io_service
+  boost::asio::io_service& g_io;
+};
+
+} // namespace tests
+} // namespace nfd
+
+#endif // NFD_TEST_COMMON_HPP