updated matrix.valid and its test specs