Finished code for logic tests