[Bug 907224] Fixed advanced search with products error

Any advanced search with at least one product selected will fail with an error. This patch fixes that with unittests.