restructured backend code, more tests