a few unit tests, bugfixes, py3 compat