Fix error in batch scanning, which led to a unittest failure in random

runs for MVCC stats.
Yes, I'm pretty sure I don't want to move this code into C++. That would mean less visibility from the main application in Go and different C++ code to handle cases of different backend storage engines as they're added. Right now moving to use DB.cc would mean we couldn't use the in-memory engine for unittests.