Fix integration tests with a check for nil
Add a unit test to validate behavior