Implementing tests and refatoring code.