Refactor tests to use the same helper function.

This eliminates a function that was not used in some cpp files and could
cause a compiler warning.
Refs #8378
Merge branch 'feature/8378_gamma_correction' into develop