Add chatty-history tests
This MR also modifies chatty-history.c to fix the failing tests. !381 (merged) has been merged into this.
Please note that this is going to be partly re-written after the database is made async. Tests are added before so that making history async won't be broken.
/cc @guido.gunther