Use macros to simplify test code

Change-Id: Ie28e50d77304e50f76822593644b93f39223e529