simplified shutdown and fixed unit tests