write() fixes, first simple test passed