fixing write header and adding test