Fix bug in hasMany.set when models have custom primary keys, add unit test