Fix various integration tests

See detailed description in each individual commit for more info.
Doh, this wasn't supposed to be in there! Will delete.