test all of Foundation, fix some bugs in it