add tests, minor fixes