Add support for hasMany-through and more tests