Refactor of error messages raised and fixed bug #24