Refactor unit test helper functions

Avoid the need to recompile for each test function called when multiple
functions are being tested in the same test case (e.g. extintr.cs).