So, uh, the global context stuff never actually worked. Oops.

Fix it and add some tests in case of regression.