[METRICS-390] Fix string handling for TSDB prefix and tags

Fix some bugs in my earlier PR