Handle Lwt.fail with Lwt.fold_left_s
factorize code in new module