Fix misassigned build, refactor + more tests