Change TabDatabase to TabBroker, refactor, add tests