Added tests and cleaned up variables to improve functionality.