Updated json writes and updated tests