improve some error messages and add failing tests for bug