Refactor and test batch API.
Reject all promises when batch request failed