fix server loop-breaking behavior for unexpected cases, fix tests, re-edit cas generator, re-edit and finish implementation of daemonizing