There is no practical risk here. While skin to skin contact like this can transmit certain STIs, since the contact was so brief and not vigorous, there is no chance of transmission.
Skin to skin (direct, unclothed oral to genital, genital to genital, genital to anal) contact that can result in transmission requires heavy, prolonged rubbing or grinding, usually the kind associated with intercourse.
There is also no risk from mutual masturbation.
There's no risk here, no need to test, and no need to worry.