Add a better test for service environment variables. Fix bugs.

Closes https://github.com/GoogleCloudPlatform/kubernetes/issues/876
Recommend extracting a function or at least leaving a comment that any changes here need to happen in multiple places.