Fixed issue in MemoryStorage, and added new tests