Tests for basic backend handler.
Added more tests and fixes.
Merge from testing branch. Added more tests and fixes.