made toPattern() call toString() to eliminate code duplicate and improve
code coverage