use pidlockfile, should fix #40
Merge pull request #41 from medea/pidlock

use pidlockfile
handle case when db is not opened correctly
DRY test
sync & mapReduce