Refactor class name validator to use new uniqueness test.

Add unit test for class name generation.