Add test for the memoization of functionals