Added memoize functions and its tests