Improve removeTask and test it