R : Performance of clusterApply deteriorates when called inside a function