flexible function for testing a fn