move test code out of main module