Used some nicer syntax and added an indented writing unit test.