add full pattern test
and do more code cleanup