renamed confusing variables
tag attributes validated
tests for tag attributes
removed some redundant lines, log messages and unused vars
renamed format to write as more meaningful
added a new test