break flag parsing into its own method, add tests
fixup on failing test