I tried using your template in a custom column and it produced a result, so it isn't clear what your problem is. What problem are you are having? Where are you using that template when it doesn't do whatever you want?
As an aside, you might be better off using something like
Code:
{series:'test($,
template("Knihy/_[[series]]_/[[series_index]].[[title]] ([[author]])"),
template("Knihy/[[author_sort]]/[[title]] ([[author]])"))'}
Expressing the result as a template evaluation seems clearer to me than doing it as a series of concatenated values.
Even better (for me) would be to use general program mode, letting you use {} instead of [[ ]] to bracket field references in the template.
Code:
program:
test(field('series'),
template("Knihy/_{series}_/{series_index}.{title} ({author})"),
template("Knihy/{author_sort}/{title} ({author})"))