gen-test refactored