TEST: try to avoid Out of memory by replacing foldLeft by reduce