Finished code for first three tests