Refactoring router.go to handle errors. Improving code coverage.

Refactoring router.go to handle errors. Improving code coverage.
Should we also print the error here?