added python version of the test
reorganize the code