More unit tests for query rewriter