Fixing bug when re-instantiating the activity.
Added some tests