Refactored to make use of string formatting

Added Tests