Implement in-memory storage backend

This pull request extends the storage API slightly (to add a finalise operation) but the bulk of the changes are to implement the in-memory backend.

Done:

- Add finalise operation to the storage API;

- Implement in-memory storage backend;

- Write tests for the in-memory storage backend.