This fixes the issue #2

Added tests, added atomic transactions, option to fail fast on error.