Reduce boilerplate code in tests