Authentication n stuff

First implementation without trusted hosts, added tests