Refactored out actual test code from test.c