Cleanup duplication in test_backend

There was some code duplicated in test_backend so this removes
the duplication by providing a function.

Change-Id: I6635f98932812fe2adae04feed9c07f3aa81eb5d
Merge "Cleanup duplication in test_backend"