Fix leaks in buffer tests