Code refactory for vm tests

Code Refactory for vm tests