Refactor both tests and production code by removing all magic numbers