add generics, clean up the code
give the test some love
some more code cleanup and generics