refactored and added tests for predicates

SqlPredicate and PredicateBuilder no longer implement Predicate
interface.
Simplified query planner, fixed small bugs.