added some tests and wrote the cloning function