Refactored url rewriting. Intermediary commit.
Fixed UrlRewriterTest and removed some duplicated tests