Use function pointer in testing

Useful for eliminating repetitive allocation code in RunTests