pass a Reader to constructor instead of a file

It's easier to test...
got fmt
namegen: add test and fix bugs