Refactor and add tests to make sure we don't split filters on whitespace