Refactor regexp annotator, add tests