Fix case where the wrong term object is deleted. Steps on T477.