Fix oveflow and transfer algorithms, more tests