Fix leaks in unit tests