Hotfix/fix wp csv export

@TribesTom thanks for the [PR](https://github.com/opf/openproject/pull/2366). 

I tested it and it is working splendidly. Kudos for that!

I added some amends to it while reviewing the code:

* Fixes failing specs
* Fixes whitespace/styling issues
* removes unused variables
* sets the title to the name of the query or sets a default
* refactors the code to be cleaner

Functionality-wise I hope to not have change anything except for the title being displayed. Can you please tests whether this works for you?

Thanks for the good work, I could really build on it. When accepting the PR, this should also update your PR on OP.