Fix for zero-sized content throwing off toChannelBuffer(). Also
short-circuit writeTo(..) accordingly to avoid unnecessary work.

Fixes #5543
Assorted fixes for bugs in the PagedBytesReference tests, plus a typo
where the wrong variable was used for a calculation.

Closes #5549