Fix #50: error when modules loaded twice
Nicer exception handling and testing