criteria: fix issue #2157 and added tests

See pull request https://github.com/phalcon/cphalcon/pull/2208