Replace usage of mock with double
Prefer literal nil over NilClass in when condition