Test higher-order function