test and fix for functions that returns inner functions