Test fixes. Changes to code to facilitate the tests