Fix bugs in buffer wrapping found by the tests
Fix bugs in buffer wrapping found by the tests

MichaelLiZhou/log-courier,scrapinghub/log-courier,srizzling/log-courier,scrapinghub/log-courier,dixitk13/log-courier,MichaelLiZhou/log-courier,dixitk13/log-courier,srizzling/log-courier,scrapinghub/log-courier,linearregression/log-courier,linearregression/log-courier,MichaelLiZhou/log-courier,linearregression/log-courier,dixitk13/log-courier,srizzling/log-courier