Consolidate connect methods & add tests
Fix bugs uncovered by last commit

Also consistently use malloc instead of jl_alloca in fs.jl