Test write function against error from API