Extracted duplicate code from test