Cleaned up the test class
Code cleanup, smarter error handling