Backport of 8f8dc830dfeb321b0de3325a8d2c859fdc20c3af from master
Setup QUnit, added tests, and measured test coverage. Thanks to Nick Sanford for the initial tests.