fix memory module, add tests