Lock buffers in flush and close. Additional test for invalid unsigned
values.