Improved test cleanup for environment-variable-based configuration.