Fix searchPosts; write remaining tests

The important thing here is fixing the searchPosts function (oops, missed it before. Sorry!).

Wrote tests for the remaining functions as well.