added tests to translate.py and refactored it