Fixed some tests and code analysis
Removed duplicated cache factory definition
Refractored cacheFactory

removed some lint errors
Fixed some jshint errors