Copied implementation from str_pad()
Added test cases