integration tests: refactor common functionality