fix randomly failing tests due to improper teardown