Added some error checking to texture class
Catch unexpected exceptions in unit tests.