fix tests for changes
fix rearrange if to be more efficiant and easier to test