I found a way to make it work. I divided the research ability into smaller research abilites - each one can only research one upgrade and they are all on the same building and each one has its own validator. In this way, the UnitCompareOrderCount validator works exactly as you describe it! It works for train, morph and now research abilities, as long as research only contain 1 upgrade!
Thanks for your help