split unit tests
diff --git a/.gitignore b/.gitignore
index fd41a2e..b82214e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,5 @@
 doc/xml
 
 benchmarks/files/numbers/*.json
+
+*.o
diff --git a/.travis.yml b/.travis.yml
index ffe05ec..4af6bf7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,7 +24,7 @@
         - make clean
         - touch src/json.hpp
         - make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage -std=c++11 -lstdc++" CXX=$COMPILER
-        - ./json_unit "*"
+        - test/json_unit "*"
         - coveralls --exclude test/src/catch.hpp --exclude test/src/unit.cpp --include src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9'
         - bash <(curl -s https://codecov.io/bash)
       env: COMPILER=g++-4.9
@@ -164,9 +164,9 @@
   - uname -a
   - $COMPILER --version
   - make CXX=$COMPILER
-  - ./json_unit "*"
+  - test/json_unit "*"
   - if [ `which valgrind` ]; then
-    valgrind --error-exitcode=1 --leak-check=full ./json_unit ;
+    valgrind --error-exitcode=1 --leak-check=full test/json_unit ;
     fi
   - if [ `which brew` ]; then
     brew update ;
diff --git a/Makefile b/Makefile
index 70e8859..199d65d 100644
--- a/Makefile
+++ b/Makefile
@@ -12,18 +12,20 @@
 	rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM
 	rm -fr benchmarks/files/numbers/*.json
 	$(MAKE) clean -Cdoc
+	$(MAKE) clean -Ctest
 
 
 ##########################################################################
 # unit tests
 ##########################################################################
 
-# additional flags
-FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal
+# build unit tests
+json_unit:
+	@$(MAKE) -C test
 
-# build unit tests (TODO: Does this want its own makefile?)
-json_unit: test/src/unit.cpp src/json.hpp test/src/catch.hpp
-	$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@
+# run unit tests
+check: json_unit
+	test/json_unit "*"
 
 
 ##########################################################################
diff --git a/README.md b/README.md
index c0bb61b..722bf88 100644
--- a/README.md
+++ b/README.md
@@ -501,8 +501,7 @@
 To compile and run the tests, you need to execute
 
 ```sh
-$ make
-$ ./json_unit "*"
+$ make check
 
 ===============================================================================
 All tests passed (8905012 assertions in 32 test cases)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index c66b19c..4d12de3 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -3,6 +3,7 @@
 add_executable(${JSON_UNITTEST_TARGET_NAME}
     "src/catch.hpp"
     "src/unit.cpp"
+    "src/unit-runner.cpp"
 )
 
 set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..0d4edec
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,21 @@
+##########################################################################
+# unit tests
+##########################################################################
+
+# additional flags
+CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal
+INCDIRS = -I ../src -I .
+
+SOURCES = src/unit-runner.cpp src/unit.cpp
+OBJECTS = $(SOURCES:.cpp=.o)
+
+all: json_unit
+
+json_unit: $(OBJECTS) ../src/json.hpp src/catch.hpp
+	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
+
+%.o: %.cpp
+	$(CXX) $(CXXFLAGS) $(INCDIRS) -c $< -o $@
+
+clean:
+	rm -fr json_unit $(OBJECTS)
diff --git a/test/src/unit-runner.cpp b/test/src/unit-runner.cpp
new file mode 100644
index 0000000..ec957b7
--- /dev/null
+++ b/test/src/unit-runner.cpp
@@ -0,0 +1,30 @@
+/*
+    __ _____ _____ _____
+ __|  |   __|     |   | |  JSON for Modern C++ (test suite)
+|  |  |__   |  |  | | | |  version 2.0.2
+|_____|_____|_____|_|___|  https://github.com/nlohmann/json
+
+Licensed under the MIT License <http://opensource.org/licenses/MIT>.
+Copyright (c) 2013-2016 Niels Lohmann <http://nlohmann.me>.
+
+Permission is hereby  granted, free of charge, to any  person obtaining a copy
+of this software and associated  documentation files (the "Software"), to deal
+in the Software  without restriction, including without  limitation the rights
+to  use, copy,  modify, merge,  publish, distribute,  sublicense, and/or  sell
+copies  of  the Software,  and  to  permit persons  to  whom  the Software  is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE  IS PROVIDED "AS  IS", WITHOUT WARRANTY  OF ANY KIND,  EXPRESS OR
+IMPLIED,  INCLUDING BUT  NOT  LIMITED TO  THE  WARRANTIES OF  MERCHANTABILITY,
+FITNESS FOR  A PARTICULAR PURPOSE AND  NONINFRINGEMENT. IN NO EVENT  SHALL THE
+AUTHORS  OR COPYRIGHT  HOLDERS  BE  LIABLE FOR  ANY  CLAIM,  DAMAGES OR  OTHER
+LIABILITY, WHETHER IN AN ACTION OF  CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE  OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+#define CATCH_CONFIG_MAIN
+#include "catch.hpp"
diff --git a/test/src/unit.cpp b/test/src/unit.cpp
index 79a4bb0..a5c348b 100644
--- a/test/src/unit.cpp
+++ b/test/src/unit.cpp
@@ -26,12 +26,12 @@
 SOFTWARE.
 */
 
-#define CATCH_CONFIG_MAIN
 #include "catch.hpp"
 
 #include <array>
 #include <deque>
 #include <forward_list>
+#include <fstream>
 #include <list>
 #include <map>
 #include <set>