Code refactored/styled; new tests