add tests, refactor, and add custom format options