test: extract common code