--- a/tests/mysqld.py
+++ b/tests/mysqld.py
@@ -186,11 +186,11 @@ class MySQLServerBase(object):
             if self._sbindir:
                 break
             for afile in files:
-                if (afile == EXEC_MYSQLD and
+                if (afile == EXEC_MYSQLD and 'bin' in root and
                         os.access(os.path.join(root, afile), 0)):
                     self._sbindir = root
                     files_to_find.remove(EXEC_MYSQLD)
-                elif (afile == EXEC_MYSQL and
+                elif (afile == EXEC_MYSQL and 'bin' in root and
                         os.access(os.path.join(root, afile), 0)):
                     self._bindir = root
                     files_to_find.remove(EXEC_MYSQL)
@@ -289,7 +289,7 @@ class MySQLServerBase(object):
 
         prc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=DEVNULL)
         verstr = str(prc.communicate()[0])
-        matches = re.match(r'.*Ver (\d)\.(\d).(\d{1,2}).*', verstr)
+        matches = re.match(r'.*Ver (\d{1,2})\.(\d).(\d{1,2}).*', verstr)
         if matches:
             return tuple([int(v) for v in matches.groups()])
         else:
