added tests and debugged physics