added copy method

1195bba23fbcb33d2d69db411eb8aecccacec8e9, added copy method based on the link given on the issue, also added test for the method.