Debugged version of 4th task. Unittests will be soon.