Simplified the optimize function (ScalaCheck with the old one tested in tomtau/mockup)