Fix generics and tests