improve test framework, add some more tests

I don't know if this it too much for one pull request. I can break it up into parts (the refactor and the tests for "blush this").
I was also going to add some tests making sure opening a private browsing window worked, but it turns out there's a conflict with panels and private windows (see bug 816257).
There are yet more tests to write (and certainly as we add functionality), but I thought it would be good to just start with this.