Fix the behavior of ensure(n) at the buffer boundary
Add test that unpack data at the buffer boundary
Fix extra buffer switch