Created by: camdencheek
Fixes https://github.com/sourcegraph/security-issues/issues/274
Added tests to ensure errors are returned where expected.