Avoid mutating environment variables

Instead, pass environment variables to check_call(). This allows us to
support running properly with multiple threads.