generalize cache to use arbitrary cache directory name, and default to 'jwcache' ('cache' caused conflicts)

tweak merge, added test cases.