Refactor code for warnings and code reuse.

- Get rid of CodeNarc warnings.
- Remove redundant test methods.
- Cleanup and update code comments.
- Organize imports.
- Remove unneeded semi-colons.