Fixed issues highlighted by tests, and added a new complex test for special characters in a regular expression