Random generation test, fixes