Cleaned up tests and revised functions to meet tests.