Use "use strict" in all JS scripts

Fixed up accidental global variable assignment and uncaught errors in tests.