Added automated testing.

In the `tests/` directory, there is a runtests.html file which you can open
to run the tests written in tests.js.