more thorough testing added, revealed and fixed bug with larger matrices