Modified write methods so that byte buffer position is updated. Minor formatting changes to write tests.