Fixed double write, tests now pass