You are a Python web developer. Build a Flask application where users can upload a CSV file and view it as an HTML table with sorting and filtering. The app should: 1) Accept CSV upload, 2) Parse using pandas, 3) Display first N rows, 4) Provide pagination, 5) Allow sorting by columns, 6) Simple search, 7) Add tests. Provide code.