improve reseting environment before loading environment file, fix #2461