refactor code common across tests into testRunner