Fix copy-paste bug
Some tests
Working version of second iterative algorithm