Updated tests and centralized some of the functionality