add tests for sorting and filtering functionality with bug fixes for bugs found by tests