Fixed GetLastValue & GetLastKey

As stated in in issue 353 they don't work correctly because they trying to find the next index of the last value/key which doesn't exist.