Tidied up in the code and unit-testings