Added unit test and cleaned code.  Refs #7652.