Modified tests and fixed outstanding areas in the code to match tests