Added test. In some cases $result is null

Replaces https://github.com/owncloud/core/pull/7375 by adding also a check whether the value is empty

@MorrisJobke @schiesbn