extract option merging into separate package & refactor/add tests