fix issue with extract closure into template
add new line before closure def if not first expression in block
add getClosureNameOccurrences functionality
clean up getClosureNameOccurrences
add getClosureParamsOccurences functionality
extract common code