Fix a nasty off-by-one problem with BDB backend (result from earlier refactoring; gap in test coverage)