move test code to main