remove randomness in app name and service_instance name

so that we can reliably clean up before ourselves
refactor to improve readability
restore env after test

we modify HOME, GEM_HOME and GEM_PATH in tests. Better not to bring this
pollution to subsequent tests.