Got the tests running again.
Fixed bug with start or end document token never found.
Made the the rule more efficient by compile pattern only once.