Updated documenation and added tests (and fixes)