Added code to link against magma and fixed the test suite