improvement of utils.buffer and tests to account for it