Migrating code form test.py to msgrpc.py