saveStorageModelCommand: add tests, fix stream not being flushed bug