Fix memory leak in hash tests