added test. fixed bug in simple rewriter.