Fix expand() and made unittests more robust