Refactor and initial testing of setup_db

### Changelog
* Cleanup of `node/setup_db.py`.
* Some schema abstraction.
* Simple tests.
Do these have any test conditions?