Minor tweak to tokenizers where it would crash on some invalid inputs (+ regression test)