This commit also adds another test for formatting, and fixes an issue where the final newline was not appended to a formatted document.