ts_stdlib: more unit tests, more fixes for badly implemented code