[#307] fixed deep copy of class defined objects references

also added more tests in the provided example