Add unit tests.

It is racy. I introduced a new getProcessEnv_ function so that tests can avoid using the real process.env.