add tests for memoization