fix tests to API changes
fix error when using write() or writeAt()