Refactor integration test to use a factory