updated testCacheMatrix function