Fix crashes and assorted issues with nested queries

Filtering a query on a TableView does not copy that TableView, and in fact the
TableView needs to remain alive for the query to be able to update, so keep a
reference to the parent RLMArray when querying or sorting an existing
RLMTableViewArray.

This is somewhat ugly, but should be rendered irrelevant by the switch to lazy
queries.

Closes #789, #818, and #837.