Add a better test for service environment variables
Fix bugs.
Merge pull request #944 from brendandburns/service

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