Chained batch wait

Chained batch now can be called before the database is opened. Also cleaned up a bit by moving `Batch()` to a seperate file. Test added of course :)

This is one of the points in #174 and also fixes #142.