Refactor RegexpFactory into its own file

Also fixes up a bunch of spec idiosyncrasies.