Due to the bug in object serializer, when template() contract
serialized the template to a dictionary, instead of object IDs
for the objects outside of serialized tree it put the object body.
Thus when new objects were created from the template, they all
had copies of that object with different IDs rather than copies
of the ID string (i.e. references to the same object).
Also template() contract tried to serialize the template on each of
the 2 object model load passes even though the result from the first
pass is never used. However, during first pass the model could contain
forward-references to objects that are not loaded yet so attempt to
serialize such model could fail.
Change-Id: I9d81f10c160c44e6405b54f5470904064c1d4852
Closes-Bug: #1689769