Removed some ugly duplicate code in the test file