refactor mem.js
tests for MemAdapter
more tests for MemAdapter
Merge branch 'mem_refactor'