Added more formatting unit tests and updated code to fix problems.