added tests and caching