more unittests and fixes