Fixed caching and collector bug
Added tests