Refactor and initial testing of setup_db

### Changelog
* Cleanup of `node/setup_db.py`.
* Simple tests.