fix copy assignment operator for unit

The new version is exception safe, using copy and swap, and should
be correct with reference counting.