Fixed up try/catch and added tests