Generalize bulk_operations logic

LMS-11366

@nasthagiri @cpennington please review
s/bulk_write_error/bulk_write_record ?