Update new_ex.py

Updated the previous script with unit test in the same source file.
Overall pylint score: 7.96