Add unit test, fix History Window element deletion