Improvement per @wkeese feedback: embed testing code in function argument