Avoid code duplication in tests