fixed security, caching issues and added more tests