Improved random test of main
Added regression test 7