def _RemoveKnownAnomalies(test, change_points):
  """Removes some anomalies and updates the given TestMetadata entity.

  Args:
    test: A TestMetadata entity, which has a property last_alerted_revision.
        This property will be updated when this function is called.
    change_points: A list of find_change_points.ChangePoint objects. It is
        assumed that this list is sorted by the x_value property.

  Returns:
    A list of objects with the property x_value.
  """
  # Avoid duplicates.
  if test.last_alerted_revision:
    change_points = [c for c in change_points
                     if c.x_value > test.last_alerted_revision]

  if change_points:
    # No need to call put(). The given TestMetadata entity will be re-used and
    # we don't want to modify TestMetadata entity in the datastore.
    test.last_alerted_revision = change_points[-1].x_value

  return change_points