Added final QC test functions and debugged based on tests