Move test logic into a function for re-use.
Move test logic into a function for re-use.

Change-Id: I29ad81ee0f15a969a3d7d89b644b8044af4fd1da

jmorse/cyanide,jmorse/cyanide,jmorse/cyanide,jmorse/cyanide