fixed a test, factored other things out of main