Added small fixes and unittests