fix copying and add better tests for it

@jone can you take a look at it? Fixes #24