Enchance/mw/bg manager

Add tests for coverage of exported api, and removed unused/old code in the process.