add tests, fix a few issues