If you add a class, you will not be able to reference it by its namespace until you have purged the Moodle cache.
When you do that Moodle rebuilds its list of classes. Thats probably why your code was perfect, but it took the uninstall/uninstall for Moodle to notice how perfect it was.