MatrixHandler

Added more test to improve percentage of code coverage and optimize some
"if" conditions in some methods, also reviewed and applied PEP08 and
PEP257.