Added method and test for copying an object