Added tests and refactored so we have a testable label function