clean up of main, second testcase refactored