Fix memory leaks in pipeline cache tests