Fix up tests and get ready to enable CI

This looks like a lot of changes, but it's mostly under tests/* as I was refactoring/fixing a bunch of the testing infrastructure. I also switched to using firefox as our main test browser instead of phantomjs. I found myself fighting phantomjs bugs a bit too much, and chrome is more painful to setup (although we'll definitely want to add it eventually). The main advantage of phantomjs is startup time, but the difference is negligible after the first run.

The only non-testing related change is a bug fix to shell/shared/db.js