Adding test case for defer within closures