Solid union success according to geometry order

I have definition which generates frame pieces and then UNIFY them with Solid Union.
I have noticed that sometimes the success of SOLID UNION depends of geometry order. Which does not make sense for me. Anyway, since there is a high number of elements I cannnot always correct the order manually. Is there a way which check if Solid union succeeded and if not, the script plays with the order until it is ok?

solid order.3dm (131.0 KB)
solid (7.7 KB)

just as info: in Rhino7 service release candidate 7.7.21145.13001, 2021-05-25, it works both ways