Fix various integration tests

See detailed description in each individual commit for more info.
Three seconds seems pretty arbitrary. Maybe this should be configurable?