Tests and fix for duplicated attributes

fixes #865