Fix warnings in unit tests, and reformat some files