improve having

* all current druid having functionality supported
* tidier code in query.rb
* less repetition in having.rb
* better specs