Login tests plus some fixes