refactor: the whole thing
test: add initial tests