moving you pokemonsters in the storage doesn't work either. It seems like the monster you want to swap doesn't know where to go, and just gets deleted. the duplicates are a half visual bug. If you swap both into your team, the level doesn't know what to do and swaps the stat up and downwards. When you put them back into storage, the duplicate will be wiped and you only have one monster again. a duct tape solution could be, that the second monster you want to swap with, will be treated as a new monster and gets put at the front of the box.
Maybe it's just a timing thing. moving both monsters in the code at the same time could be problematic.
hopefully some of this works. good luck :)