Correctly update block-counter when buffer length isn't block-size aligned

Test.
Add missing #include.