Fix bugs in "Bytes left" session info calculation.


Factor out piece-length calculation in case we want to call it from more
than one place.