Fix issues that were preventing tests from running

Apparently require is no longer available through bower, which was causing
my test suite to fail completely. I ended up doing some refactoring, which I
think resulted in a cleaner structure.
Refactor tests to reduce chance of using wrong jQuery

The previous way the tests were written made it too easy to accidentally use
the "global" jQuery when it was intended to use the sandboxed version. The new
convention is to call the global one `jQuery`, and the sandboxed one `$`, and
to always use `$` rather than assigning to `this.$` or similar, which was easy
to get wrong in the tests due to muscle memory. Utility functions from the
global jQuery are also exposed in the closure so that you don't have to worry
about which version of jQuery to use to access them. Whenever the script is
outside a test, `$` should be `null`, which will make it clear that it was
misused, since it will cause an error.