If you have a unique-equipped gem in say your chest piece in the set you are wearing and you switch to set #2 with the same unique-equipped gem in your legs, switching in your legs will fail sometimes as it tries to switch the legs in before the chest is out.
Holy crap, that problem sucks.
Hope I can fix that, but I'm not going to try yet, maybe in a few weeks, a month or so.
Having dealt with that kind of issue in a different environment, my suggestion on how to deal with it is fairly easy, the only complication comes from how you can detect the failure. If the call to equip the item returns a status, it's easy, otherwise you have to check to see if you really equipped the item, and I'm not sure how much overhead would be involved.
Basically, you loop on equiping the items (either the entire set, easiest to code, or just the failed items, probably more efficient), and drop out of the loop when you either equip all items or you fail to equip any items (that weren't equipped in a previous iteration). Worst case, this would be an order N^2 algorithm, but I don't see it ever devolving far enough to be an issue.
A more elegant solution, but a good bit more work, would be to do that the first time, and remember the order you successfully equipped them.
Trying to code this looking specifically for unique-equipped gems would be a nightmare, and would be special case for that one problem, rather than dealing with similar issues in the future. It might provide an alternate solution to the offhand weapon issue. I haven't been tracking that so I don't know what the current solution is.