Tests and fixes for join cost calculation.