Added a mechanism to serialize and restore database images for easier testing.