Refactor matrix module
Rename functions module
Refactor tests