Fix bug with macro expansion
Add matrix tests