Grouping by Category with Multiple Keys
Try adding square brackets around your object:

{% set testsByAllergenGroup = testsByAllergenGroup|merge([{ (group.title): entries }]) %}


Update:

First thing I'd change is to set the object keys to something unique (slug or id works better than title).

To feed the object with all properties you need (so you don't need to do further DB queries later), do the following.

The values of your object can be objects too, this allows you to assign more data to each individual key.
You could define a custom key for each property you need for your output (i.e. 'groupId': group.id) or
pass the whole category model (see example code below), which allows you to access all of its properties in the output loop.
With the entries you need to make sure to assign an array of entry models and not an ElementCriteriaModel! So make sure to
add the find() method to your craft.entries call.

{% for group in groups %}
    {% set entries = entries.relatedTo(group).find() %}
    {% set testsByAllergenGroup = testsByAllergenGroup|merge([{
        (group.slug): {
            'group': group,
            'entries': entries
        }
    }]) %}
{% endfor %}

{% for key, value in testsByAllergenGroup %}
    {{ value.group.id }}: {{ value.group.title }}
    {% for entry in value.entries %}
        {{ entry.title }}
    {% endfor %}
{% endfor %}