refactor converter and add tests