improve teardown_config_session() and add corresponding unittest