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

Closes #5549