fix spatial bugs and more tests