Rework unit tests so they will not overflow naive algorithm