Add tests for broker id and port
Reduce duplication of test code