Added test cases for additional coverage

Also moved setup_db command functionality to independent file.