The issue is not with spaces. The issue is with your misunderstanding of the functionality of the vl-string-right-trim function.
The string trim functions will trim all occurrences of the supplied characters from one or both sides of a string, hence the return from your test is correct since the character '4' is trimmed twice.