Hi, the idea is great but in pt-BR “ao referir” without any pronoun sounds lacking something (the pronoun…).
Also, “quando refere-se” is not in accord with standard norm, should be “quando se refere” if the rule you created is not to be used if for some reason it doesn’t work.
Hmm, not so sure. For me, “Quando a mensagem é verificada” there is no agent, now in “Ao verificar a mensagem”, it seems that I have checked the message, don’t you feel the same?