added error messages and updated test