Fix various integration tests

See detailed description in each individual commit for more info.