test: extract common codes as methods