cleaned up most testing code and added comments