Five-wicket haul for on-loan seamer sets up visitors before Gloucestershire fight back with ball