Create with_env helper for tests.

cc @senny