Moved functions out to test