Clean up the class listing code and add some unit tests