tag writing fixes + test