Some refactorings and new integration test cases