Fix bug and add Unit Test for function "GetElem".