Fix buffer tests memory leaks (#1165)

* Fix buffer tests memory leaks

This change fixes buffer tests, broken by PR #1082. This pull request is similar to #1160

* Fix formatting
2 files changed