Correctly set matching_character_codes for negated patters, fix tests.
Add some helpers for character classes