Fix patternProperties bugs. Do pattern validation on the regex. Add new unit tests.