Make the testing of resource loading easier

Pass an environment object around so tests don't have
to use the global object and then conflict with other tests.

Change-Id: I0d9a0d3bd825ac415847213ee4a5d7473f80dbd6
Partial-bug: #1236107