Network controller refactoring and tests.