implemented centroid generation by mean and tests