Fixed + updated tests

Had to open write stream before reading attribute, weirdly.