add some minimal unit tests, fix some bugs (#9)