fix removeAttribute bug
write() tests, cleanup