separate query bindings
clean up code and formatting
added more tests
fix join binding order
update addDateBasedWhere to use addBinding