added unit tests and fixed bug related to restoring objects with read_only attributes