Simplify testInsertReadDb test case

Refactor the code.