[autotests/unit/engine] Fix memory issues in tests
- Don't leak PostingIterators by wrapping them with unique_ptr
- Avoid potential detaching of Qt containers by wrapping them with std::as_const
Now valgrind happily reports zero leaked memory for engine tests, and clang-tidy don't produce warnings (splitting unrelated changes from !91)