(LUN-782) Fixed logic bug and added more tests

Validation errors are now properly shown;
Added some more tests for checking whether template name extra trailing whitespace is properly removed.