Some changes to AbstractBulkApi to make it more testable, and some tests