Refactor test codes.

Use `Integer#times` to avoid duplicated test codes.