Fixed a number of minor bugs uncovered in new integration tests