refactor tests, fix bug in NeDB