Refactor test data generation and remove duplicate test