Refactored and added more checking to integration test