Fix several memory leaks in the unit tests.

Also add a comment to buffer.c about why we call
evbuffer_file_segment_free on failure to add the segment.