fix checkDuplicated and add test