improved cleanup in bg_manager_tests