modify handling 16bit matrix and add test function