Move test code into separate module