Batching functions to ease creation of batched calls

Reuseable generic batching logic, should make it easier for other projects to create batched calls.
- Optimal batch size is calculated
- fold function makes sure final result is coherent with what a single batch would yield.

@mmimeault @clementgarnier