Fix up all the memory leaks in the original attempt at the Handler UTs

Fix up all the memory leaks in the original attempt at the Handler UTs