Refactor test generation/extraction