Breaking out the worm flag map bits into their own file

and getting them under test