fixed and added unittests