Introduced a dictionary based cache

Also fixed tests