Refactored unit test macros to only call functions once