integration test and refactoring