fix snapshot
feat add snapCount parameter
merge with 0.2
test add snapshot tests
refactor use defer
refactor change cmd argument snapCount to snapshotCount
Merge pull request #281 from xiangli-cmu/fix-snapshot

 fix snapshot