Well, sometimes, if you have difficulty getting Behat to do what you want, it is a sign that you have an accessibility problem. If all you can see (or hear) are three choices: "Edit cohort name", "Edit cohort ID" and "Edit", because you cannot see the shape of the icon, do you have any idea what 'Edit' is going to do? Perhaps the best option is to use a better alt text on the icon, or add some class="accesshide" text to disambiguate.
Incidentally, I assume that at the moment, if you have multiple cohorts on the same page, the links to edit each cohort will be identical. That is also not great accessibility, although you found a way around that in Behat.
The other part of the answer is that you can teach Behat to be cleverer. For buttons, at least, it does prefer an exact match (since Behat 3.x which we have been using for ages). See MDL-44584 for some history. Perhaps a similar change should be implemented in the 'icon' selector? Also, not that "link" can often be used instead of "icon", and that probably gets the 'prefer exact match' logic right.