Created a more sophisticated test and also corrected a couple bugs.