Some integration tests and some shutdown function fixes