datastore: refactor transaction & datastore.

Hello again!

I rearranged a few things, hopefully for the better. I'll leave comments. :)
@rakyll - ignore that last ping. My last syntax change busted the `cover` script, so I just reverted that. Verified that `regression-test` and `test` works as expected with these new changes.