src: add missing context scopes
Add scopes that ensure that the context associated with the current Environment is always entered when working with it.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines