More tests

I'm submitting this as a PR as it contains quite a bit of work, giving around 38% test coverage.

I still plan to add more tests, but just spotted what I think might be a bug, and would like to get this work merged (if possible) so I can concentrate on writing a test case for and fixing that bug (around the behaviour of getCssMatrix()).

Note that this also fixes some whitespace issues in the Gruntfile, which I noticed after rebasing from master.