Work around more threading issues in the unit test.

As we now have another scene around we also have to destroy
its threads during testing. Also have to take care of
registry thread in other tests.
Add serialization and deserialization support.

* Switched to 128 bit IDs to eliminate risk of collisions
  in a copy heavy environment
* Introduced concept of 128 bit request id to match replies
  to requests. Used in new commands.
* Added capability to serialize and deserialize elements
  in the backend identified by their IDs. Child elements
  are recursively serialized too. When deserialization
  all involved elements receive new IDs. Connections are
  restored only if they aren't connecting outside of the
  serialized set of elements.