Total money limit test

#3707 with added intermediate overflow check by @il--ya.