Fix timeout tests, close #304
Use StringBuilders instead of StringBuffers, close #305