Fix a bug in ClassNameCleanup that prevented output to be written properly and added unit tests to prevent this kind of bugs