Refactoring and testing in the Router.

The router really is the core of any MVC server, so it's got to be
robust. The tests aren't completely exhaustive (some of them are a bit
integration-y, as I've not quite got modules isolated enough yet), but
they are better than nothing.