Add testcase for rewrite
refactoring
Add some test for rewrite