Fix ClassCastException in end of tests