add tests, fix details