added apply_func and tests