wip: add more tests and fix&improve api