Further improve finally block de-dup and unit testing