fixed memoize decorator and unit tests