Formatting, condensed some testing logic to remove duplication.