fixes #35 - syncronized terminalSession. Cause error during concurrent
json requests
* Avoid NPE
* better REST exception handing