refactor the test generation