[misc] Add test helpers

(cherry picked from commit 784e6bcade962e3de4115055abbf6fcc5dcdc7ff)