[Improvement] Replaced push.apply() calls with custom concat() function.

Replaced push.apply() calls with custom concat() function so the V8 stack will not exhaust when a complex query is being processed. It doesn't change the behavior in Knex (tests are passing), it just uses different approach to concatenate to an existing array and provides ability to simply reimplement 'concat' function if new, better approach has been found.

With this change we can run really complex queries on our server without V8 terminating the app.

NOTE: This PR also contains fixes to counting, hope that it's fine.