Replaces global protection with sandboxing
Use local copy of function
Sandbox functioning
improves tests