Refactor code to make it easy to do dependency injection
Minor tweaks to the cardinality model

* Make sure selectivities are ordered before calculating their
  weak dependence
* Use output cardinality of expand for calculating it's cost
* Simpler QueriedGraphStatistics implementation of index
  selectivity
Merge branch 'refactorings'