fix formatting errors, add test function to facilitate dev