move test code to test.c