Add make_immutable helper and use it in tests