refactoring, and a set of macros to reduce redundancy in tests