buffer: fix _resize some more
Add more debug. Alow resize to 0 bytes. Do clipping correctly. Add more unit tests. Also add a failing test: when we resize to 0 and then try to resize back to the original size it fails because the memory was removed.
Showing with 25 additions and 5 deletions