Fix integration tests, improve unit tests
Make integration tests predictable