Hi roujesky,
I am really puzzled by the problem that you are facing. I am writing a better test script to sent you which you can use to debug this better.
Can you check which hardware version is written on the back of the motor driver. The one that I have is v1.3. When and where did you buy this from?
The problems looks like it is coming because of the instability of the I2C on the motor controller. Also, do you an arduino or an ISP programmer to update the firmware on the motor driver.