Fix CodeNARC violations and unit tests.