Fix element clonning, add tests