Refactored UrlRewriter and unit tests