Added test for set_env and restore_env
Fixed problem when invoking set_env multiple times