Adding unit tests and cleanup for CAAERS-6886.