unit tests for rewrite added
rewrite patterns fixed
rewrite bugfix