better style, more tests for cache functions