So what is your suggestion to getting the right values?
You could start by posting the output of magneto, so that other people can have a clue what you are doing.
Then figure out how to incorporate that output into your code, without making errors.
A good test is to have your code output "corrected" accelerometer/magnetometer values, and run those back through magneto.
If you have done all that correctly, the newly calculated corrections from magneto will have zero for the offsets and the correction matrix will have "1" on the diagonal and zero everywhere else.