Fix testing scope failures when not testing

testing is now null when not testing, it can replace the TESTING variable.
Removed uses of "var" that were actually applying to the global scope to make scoping less obfuscated.