set function refactored
additional tests for set