Unit testings + minor fixes