writeCode function and testCode functions written, need to test