Refactor - extract common setup code