refactored test code to use macros and shared examples