fixed typo with logical or
added general matrix test