Added controller unit tests and made monitor more testable