Fixes an issue where filtering by post type wasn't working, since the filter wasn't being passed to the API. It also simplifies the code a bit and adds tests.