fixed errorous ClassCastException error message in Generic.
Added JUnit tests for it