Fix bug uncovered by scalacheck