Move tests out from lib/pattern.js to test/pattern.js