Fix table tests and improve table construction