Added tests

rewrote the whole thing to support serverside tests