Fix leaks in expand_test