When using the CiviCRM API to make a field primary, other fields in the set do not have the 'is_primary' flag removed. This results in multiple 'primary' fields.
Eg: Address A is primary. The setvalue API call is used to set is_primary on Address B. Now addresses A and B both have 'is_primary'.
Is this the desired behaviour?
I can see that setvalue is intended to be quite a low level function, so you might not expect it to unset is_primary on other fields in the set. But if this is the desired behaviour we should probably document it.