add tests, fix issues