refactor(history): make history an injected instance

The history module was not built as a class, but as a module with
service functions and internal state. It was then used directly by the
router. This would cause problems with mocking in tests or providing
alternate history implementations. This refactor fixes that problem and
ensures that the history capability is injected through the constructor
of the router.