fixing error and adding test