better uniqueness constraint and tests