Rewrite parser and tests