Fix tests to correctly check for raised errors