Change writeCopy signature and improve tests