fix several bugs in database + create some test data