refactor, add SharedMemory class, testing