Add unit test.
Fix for Darwin (Mac).
Revert "linux now has internal support for xattrs".

This reverts commit fe267a52f85cb48f31e61cfe2edd2a5e22d0f59b.
Unify Linux and Darwin (Mac) code.
Fix error handling on Linux.