A few tests have their own ad-hoc implementations. Add a single common one. PiperOrigin-RevId: 283601666