Refactor runTest