Refactor integration test to use events