fixes and unittests