Improve generic methods, fix tests