Using catch for unit testing