Correcting some erros and adding test script