Fix even checking in median heuristic