if (Meteor.isServer) {
  Meteor.methods({
    clearUsers: function () {
      if (Meteor.users.find().count() > 100) {
        throw new Error("a lot of users. are you running this in prod??");
      }

      Meteor.users.remove({});
    },
    getUser: function (username) {
      return Meteor.users.findOne({username: username});
    },
    getLogs: function () {
      return logs;
    }
  });
} else {
  var loginEndpoint = '/users/login';
  var registerEndpoint = '/users/register';
  var userId;

  testAsyncMulti("register and login over HTTP", [
    function (test, expect) {
      Meteor.call("clearUsers", expect(function () {}));
    },

    // Test a bunch of invalid registration inputs
    function (test, expect) {
      var testErrorReason = function (data, errorMsg) {
        var callback = expect(function (err) {
          test.equal(err.response.data.reason, errorMsg);
        });

        HTTP.post(registerEndpoint, {
          data: data
        }, callback);
      };

      testErrorReason({}, "Match failed");
    },

    // First, test registration without session
    function (test, expect) {
      HTTP.post(registerEndpoint, { data: {
        username: "newuser",
        password: "test",
        email: "newuser@example.com"
      } }, expect(function (err, res) {
        if (err) { throw err; }

        userId = res.data.id;

        // Make sure results have the right shape
        check(res.data, {
          token: String,
          tokenExpires: String,
          id: String
        });
      }));
    },

    function (test, expect) {
      Meteor.loginWithPassword("newuser", "test", expect(function (err) {
        // Make sure there is no error
        test.equal(err, undefined);

        // Make sure we logged into the right user
        test.equal(Meteor.userId(), userId);
      }));
    },

    function (test, expect) {
      HTTP.post(loginEndpoint, { data: {
        username: "newuser",
        password: "test"
      } }, expect(function (err, res) {
        // Make sure there is no error
        test.equal(err, null);

        // Make sure we logged into the right user
        test.equal(res.data.id, userId);
      }));
    },

    // Test registering with an existing username or email
    function (test, expect) {

      // Existing username
      HTTP.post(registerEndpoint, { data: {
        username: "newuser",
        password: "test",
        email: "newuser2@example.com"
      } }, expect(function (err) {
        test.equal(err.response.data.reason, "Username already exists.");
      }));

      // Existing email
      HTTP.post(registerEndpoint, { data: {
        username: "newuser2",
        password: "test",
        email: "newuser@example.com"
      } }, expect(function (err) {
        test.equal(err.response.data.reason, "Email already exists.");
      }));
    }
  ]);
}
@@ -1044,56 +1044,8 @@
 %7D,%0A%0A
-    // First, test registration without session%0A
     
@@ -2786,24 +2786,1268 @@
 %0A      %7D));%0A
+    %7D,%0A%0A    // Make sure we can register with no username, like accounts-password allows%0A    function (test, expect) %7B%0A      HTTP.post(registerEndpoint, %7B data: %7B%0A        password: %22test%22,%0A        email: %22newusernopassword@example.com%22%0A      %7D %7D, expect(function (err, res) %7B%0A        if (err) %7B throw err; %7D%0A%0A        // Make sure results have the right shape%0A        check(res.data, %7B%0A          token: String,%0A          tokenExpires: String,%0A          id: String%0A        %7D);%0A      %7D));%0A    %7D,%0A%0A    // Make sure we can register with no email, like accounts-password allows%0A    function (test, expect) %7B%0A      HTTP.post(registerEndpoint, %7B data: %7B%0A        username: %22newusernoemail%22,%0A        password: %22test%22%0A      %7D %7D, expect(function (err, res) %7B%0A        if (err) %7B throw err; %7D%0A%0A        // Make sure results have the right shape%0A        check(res.data, %7B%0A          token: String,%0A          tokenExpires: String,%0A          id: String%0A        %7D);%0A      %7D));%0A    %7D,%0A%0A    // Make sure we need an email or a username%0A    function (test, expect) %7B%0A      HTTP.post(registerEndpoint, %7B data: %7B%0A        password: %22test%22%0A      %7D %7D, expect(function (err, res) %7B%0A        test.equal(err.response.data.reason, %22Need to set a username or email%22);%0A      %7D));%0A
     %7D%0A  %5D);%0A

Add tests