Guard against null being explicitly passed to opt

If opt is falsey, initialise it to an empty object. This allows the tests later on to work without NPEing.