Changed string appends to StringBuilder
Added more tests.