Improved code coverage and redirect

The redication is done through string manipulation instead of relying on
the URI methods.