fix wrong end index
add close to allow tests to restart databases
test when inner hashes are received in strange ways